重複した出席番号を表示する処理を追加 #20

Merged
Utahshi merged 1 commits from CreateRoot2 into master 2024-06-28 01:32:30 +00:00
Showing only changes of commit 5a9d1d83be - Show all commits

View File

@ -135,6 +135,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
startActivity(toSubmission); startActivity(toSubmission);
} }
} }
//UUIDを表示するかのダイアログ //UUIDを表示するかのダイアログ
private void showUUIDYesNoDialog() { private void showUUIDYesNoDialog() {
AlertDialog.Builder builder = new AlertDialog.Builder(this); // この 'this' が問題でないか確認 AlertDialog.Builder builder = new AlertDialog.Builder(this); // この 'this' が問題でないか確認
@ -159,6 +160,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
alertDialog.show(); alertDialog.show();
} }
//ルート作成の非同期処理 //ルート作成の非同期処理
private void fetchDataAndCreateRoute() { private void fetchDataAndCreateRoute() {
//非同期処理の開始 //非同期処理の開始
@ -205,7 +207,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
if (notDuplicates) { if (notDuplicates) {
Log.d("MainActivity", "スケジュール作成成功"); Log.d("MainActivity", "スケジュール作成成功");
} else { } else {
showErrorDialog(latch); showErrorDialog(latch, myDataList);
} }
}); });
@ -223,6 +225,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
executor.shutdown(); executor.shutdown();
} }
//ルート作成のダイアログ //ルート作成のダイアログ
private void showRouteCreationDialog(CountDownLatch latch) { private void showRouteCreationDialog(CountDownLatch latch) {
new AlertDialog.Builder(MainActivity.this) new AlertDialog.Builder(MainActivity.this)
@ -242,11 +245,24 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
}) })
.show(); .show();
} }
public void showErrorDialog(CountDownLatch latch) {
public void showErrorDialog(CountDownLatch latch, List<MyDataClass> myDataList) {
List<Integer> studentNumbers = new ArrayList<>();
for (int i = 0; i < myDataList.size(); i++) {
if (myDataList.get(i).getSchedule() == 0) {
studentNumbers.add(myDataList.get(i).getStudentNumber());
}
}
StringBuilder message = new StringBuilder("保護者の重複が重大でルート作成ができません。調整してください。\n出席番号: ");
for (int i = 0; i < studentNumbers.size(); i++) {
message.append(studentNumbers.get(i));
if (i < studentNumbers.size() - 1) {
message.append(", ");
}
}
new AlertDialog.Builder(MainActivity.this) new AlertDialog.Builder(MainActivity.this)
.setTitle("警告") .setTitle("警告")
.setMessage("保護者の重複が重大でルート作成ができません。調整してください") .setMessage(message.toString())
.setPositiveButton("OK", new DialogInterface.OnClickListener() { .setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {