ルート作成画面の遷移時にformに送られた人数が足りてない場合、警告のダイアログを出すように変更 #9
|
@ -107,23 +107,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
||||||
runOnUiThread(() -> {
|
runOnUiThread(() -> {
|
||||||
if (totalStudent != myDataListSize) {
|
if (totalStudent != myDataListSize) {
|
||||||
// 値が一致しない場合、ダイアログを表示
|
// 値が一致しない場合、ダイアログを表示
|
||||||
new AlertDialog.Builder(MainActivity.this)
|
showRouteCreationDialog();
|
||||||
.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();
|
|
||||||
} else {
|
} else {
|
||||||
Intent toRoot = new Intent(MainActivity.this,Maps.class);
|
Intent toRoot = new Intent(MainActivity.this,Maps.class);
|
||||||
startActivity(toRoot);
|
startActivity(toRoot);
|
||||||
|
@ -160,4 +144,24 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
||||||
});
|
});
|
||||||
builder.show();
|
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();
|
showTimePickerDialog();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//リセットボタンの処理
|
||||||
|
|
||||||
reset.setOnClickListener(v -> { //テキストとラジオボタンの選択を消去
|
reset.setOnClickListener(v -> { //テキストとラジオボタンの選択を消去
|
||||||
setTeacherName.setText("");
|
setTeacherName.setText("");
|
||||||
setStartPoint.setText("");
|
setStartPoint.setText("");
|
||||||
|
@ -188,6 +190,13 @@ public class SetUpActivity extends FragmentActivity
|
||||||
setStartBreakTime.setText("");
|
setStartBreakTime.setText("");
|
||||||
setEndBreakTime.setText("");
|
setEndBreakTime.setText("");
|
||||||
setTotalStudent.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
|
@Update
|
||||||
void update(SetUpTable setUpTable);
|
void update(SetUpTable setUpTable);
|
||||||
//名前が一致しているかの確認
|
//名前が一致しているかの確認
|
||||||
|
|
||||||
|
//削除処理
|
||||||
|
@Query("DELETE FROM SetUpTable")
|
||||||
|
void deleteAll();
|
||||||
|
|
||||||
@Query("SELECT * FROM SetUpTable WHERE teacherName = :name LIMIT 1")
|
@Query("SELECT * FROM SetUpTable WHERE teacherName = :name LIMIT 1")
|
||||||
SetUpTable findByName(String name);
|
SetUpTable findByName(String name);
|
||||||
|
|
||||||
@Query("SELECT totalStudent FROM SetUpTable")
|
@Query("SELECT totalStudent FROM SetUpTable")
|
||||||
int getTotalStudent();
|
int getTotalStudent();
|
||||||
|
//開始時間と終了時間の取得
|
||||||
|
@Query("SELECT startTime FROM SetUpTable")
|
||||||
|
String getStartTime();
|
||||||
|
@Query("SELECT endTime FROM SetUpTable")
|
||||||
|
String getEndTime();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user