ルート作成画面の遷移時にformに送られた人数が足りてない場合、警告のダイアログを出すように変更 #9

Merged
Utahshi merged 3 commits from murakumo_setupの情報をroomに保存し隊 into master 2024-06-21 01:53:01 +00:00
3 changed files with 40 additions and 17 deletions
Showing only changes of commit 410d4f2402 - Show all commits

View File

@ -107,23 +107,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
runOnUiThread(() -> {
if (totalStudent != myDataListSize) {
// 値が一致しない場合ダイアログを表示
new AlertDialog.Builder(MainActivity.this)
.setTitle("警告")
.setMessage("人数が足りてませんがそれでもルート作成を行いますか?")
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Intent toRoot = new Intent(MainActivity.this,Maps.class);
startActivity(toRoot);
}
})
.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
})
.show();
showRouteCreationDialog();
} else {
Intent toRoot = new Intent(MainActivity.this,Maps.class);
startActivity(toRoot);
@ -160,4 +144,24 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
});
builder.show();
}
//ルート作成のダイアログ
private void showRouteCreationDialog() {
new AlertDialog.Builder(MainActivity.this)
.setTitle("警告")
.setMessage("人数が足りてませんがそれでもルート作成を行いますか?")
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Intent toRoot = new Intent(MainActivity.this,Maps.class);
startActivity(toRoot);
}
})
.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
})
.show();
}
}

View File

@ -177,6 +177,8 @@ public class SetUpActivity extends FragmentActivity
showTimePickerDialog();
});
//リセットボタンの処理
reset.setOnClickListener(v -> { //テキストとラジオボタンの選択を消去
setTeacherName.setText("");
setStartPoint.setText("");
@ -188,6 +190,13 @@ public class SetUpActivity extends FragmentActivity
setStartBreakTime.setText("");
setEndBreakTime.setText("");
setTotalStudent.setText("");
ExecutorService executor = Executors.newSingleThreadExecutor();
executor.execute(() -> {
AppDatabase db = Room.databaseBuilder(getApplicationContext(), AppDatabase.class, "SetUpTable").build();
SetUpTableDao setUpTableDao = db.setUpTableDao();
setUpTableDao.deleteAll();
});
});
}

View File

@ -14,9 +14,19 @@ public interface SetUpTableDao {
@Update
void update(SetUpTable setUpTable);
//名前が一致しているかの確認
//削除処理
@Query("DELETE FROM SetUpTable")
void deleteAll();
@Query("SELECT * FROM SetUpTable WHERE teacherName = :name LIMIT 1")
SetUpTable findByName(String name);
@Query("SELECT totalStudent FROM SetUpTable")
int getTotalStudent();
//開始時間と終了時間の取得
@Query("SELECT startTime FROM SetUpTable")
String getStartTime();
@Query("SELECT endTime FROM SetUpTable")
String getEndTime();
}