削除機能の実装
This commit is contained in:
parent
b99aa2973d
commit
410d4f2402
|
@ -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();
|
||||
}
|
||||
}
|
|
@ -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();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user