・重複時のダイアログに保護者の情報が表示されるように調整しました。
・その他細かなバグを修正しました。
This commit is contained in:
parent
02212be21e
commit
6a5eca8000
|
@ -42,13 +42,14 @@ public class CreateSchedule {
|
|||
private final AppDatabase db;
|
||||
private int arraySizeInt;
|
||||
|
||||
boolean notSecondDuplicatesBoolean = true;//スケジュールの重複の有無(第一希望日のみで通った場合も考えて初期はtrue)
|
||||
private boolean notSecondDuplicatesBoolean;//スケジュールの重複の有無(第一希望日のみで通った場合も考えて初期はtrue)
|
||||
|
||||
String[] homeVisitDaysString;
|
||||
|
||||
|
||||
public CreateSchedule(AppCompatActivity activity) {
|
||||
this.db = Room.databaseBuilder(activity.getApplicationContext(), AppDatabase.class, "SetUpTable").build();
|
||||
this.notSecondDuplicatesBoolean = true; // 初期値をtrueに設定する
|
||||
SharedPreferences sharedPreferences = activity.getSharedPreferences("visitingDate", Context.MODE_PRIVATE);
|
||||
|
||||
String firstDay = sharedPreferences.getString("day1", null);
|
||||
|
@ -57,7 +58,6 @@ public class CreateSchedule {
|
|||
|
||||
Log.d("createSchedule","day1"+firstDay+"day2"+secondDay+"thirdday"+thirdDay);
|
||||
homeVisitDaysString = new String[]{firstDay, secondDay, thirdDay};
|
||||
|
||||
}
|
||||
|
||||
//MainActivityからデータを受け取る
|
||||
|
@ -116,18 +116,19 @@ public class CreateSchedule {
|
|||
sortSchedule(myDataList);
|
||||
}
|
||||
});
|
||||
//重複がなければ開始地点の緯度経度を返す
|
||||
// 重複がなければ開始地点の緯度経度を返す
|
||||
if (notSecondDuplicatesBoolean) {
|
||||
//保護者の住所を緯度経度に変換する
|
||||
// 保護者の住所を緯度経度に変換する
|
||||
String startPointLatLngString = geocodeAddress(myDataList, context);
|
||||
Log.d("CreateSchedule", "startPointLatLngString" + startPointLatLngString);
|
||||
outPutLogSchedule(myDataList);
|
||||
return startPointLatLngString;
|
||||
}
|
||||
//重複があるときは""を返す
|
||||
} else {
|
||||
// 重複があるときは""を返す
|
||||
Log.d("CreateSchedule", "重複によるエラー");
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void setData(List<MyDataClass> myDataList) {
|
||||
|
@ -348,6 +349,7 @@ public class CreateSchedule {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
for (int i = 0; i < myDataList.size(); i++) {
|
||||
if (myDataList.get(i).getSchedule() == 0) {//重複により割り当てがされていない保護者がいないかの確認
|
||||
return false;
|
||||
|
|
|
@ -28,7 +28,7 @@ public class FirestoreReception {
|
|||
//ClassIdを引数にデータの作成を行う
|
||||
public void getDocumentsByClassId(int classId) {
|
||||
myDataList.clear();
|
||||
CollectionReference collectionRef = db.collection("testAddressArray");
|
||||
CollectionReference collectionRef = db.collection("testDistinct");
|
||||
|
||||
// classIdが引数のものを取得する
|
||||
collectionRef.whereEqualTo("classId", classId).get()
|
||||
|
|
|
@ -85,7 +85,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
|||
// firestoreの受信関連
|
||||
db = FirebaseFirestore.getInstance();
|
||||
firestoreReception = new FirestoreReception();
|
||||
Log.d("MainActivity","geocodeAddress");
|
||||
Log.d("MainActivity", "geocodeAddress");
|
||||
|
||||
|
||||
ExecutorService executor = Executors.newSingleThreadExecutor();
|
||||
|
@ -105,7 +105,6 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
|||
}
|
||||
|
||||
|
||||
|
||||
// クリック処理
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
|
@ -194,7 +193,8 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
|||
ExecutorService executor = Executors.newSingleThreadExecutor();
|
||||
|
||||
executor.execute(() -> {
|
||||
AppDatabase db = getDatabaseInstance(); SetUpTableDao setUpTableDao = db.setUpTableDao();
|
||||
AppDatabase db = getDatabaseInstance();
|
||||
SetUpTableDao setUpTableDao = db.setUpTableDao();
|
||||
int totalStudentInt = setUpTableDao.getTotalStudent();
|
||||
int myDataListSizeInt = firestoreReception.getMyDataListSize();
|
||||
|
||||
|
@ -246,9 +246,19 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
|||
final List<MyDataClass> finalMyDataList = myDataList;
|
||||
CreateSchedule createSchedule = new CreateSchedule(MainActivity.this);
|
||||
String startPointLatLngString = createSchedule.receiveData(myDataList, getApplicationContext());
|
||||
|
||||
Boolean notDuplicatesBoolean = null;
|
||||
for (int i = 0; i < myDataList.size(); i++) {
|
||||
if (myDataList.get(i).getSchedule() == 0) {
|
||||
notDuplicatesBoolean = false;
|
||||
break;
|
||||
} else {
|
||||
notDuplicatesBoolean = true;
|
||||
}
|
||||
}
|
||||
Boolean finalNotDuplicatesBoolean = notDuplicatesBoolean;
|
||||
Log.d("MainActivity", "重複判定" + String.valueOf(finalNotDuplicatesBoolean));
|
||||
runOnUiThread(() -> {
|
||||
if ( !startPointLatLngString.equals("")) {
|
||||
if (finalNotDuplicatesBoolean) {
|
||||
Log.d("MainActivity", "スケジュール作成成功");
|
||||
saveMyDataList(finalMyDataList);
|
||||
Intent toRoot = new Intent(MainActivity.this, Maps.class);
|
||||
|
@ -264,6 +274,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
|||
executor.shutdown();
|
||||
});
|
||||
}
|
||||
|
||||
private void saveMyDataList(List<MyDataClass> myDataList) {
|
||||
// 共有プリファレンスのインスタンスを取得
|
||||
SharedPreferences sharedPreferences = getSharedPreferences("MyDataList", MODE_PRIVATE);
|
||||
|
@ -285,12 +296,22 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
|||
studentNumbers.add(data.getStudentNumber());
|
||||
}
|
||||
}
|
||||
StringBuilder message = new StringBuilder("保護者の重複が重大でルート作成ができません。調整してください。\n出席番号: ");
|
||||
StringBuilder message = new StringBuilder("保護者の重複が重大でルート作成ができません。保護者に連絡して調整してください。\n\n");
|
||||
for (int i = 0; i < studentNumbers.size(); i++) {
|
||||
message.append(studentNumbers.get(i));
|
||||
if (i < studentNumbers.size() - 1) {
|
||||
message.append(", ");
|
||||
}
|
||||
message.append("出席番号:" + studentNumbers.get(i));
|
||||
message.append("\n保護者名:" + myDataList.get(i).getPatronName());
|
||||
message.append("\n第一希望 " + myDataList.get(i).getStartDateString().substring(4,6)+"月");
|
||||
message.append(myDataList.get(i).getStartDateString().substring(6,8)+"日");
|
||||
message.append(" " + myDataList.get(i).getParentStartTimeString().substring(0, 2));
|
||||
message.append(":" + myDataList.get(i).getParentStartTimeString().substring(2, 4));
|
||||
message.append("~" + myDataList.get(i).getParentEndTimeString().substring(0, 2));
|
||||
message.append(":" + myDataList.get(i).getParentEndTimeString().substring(2, 4));
|
||||
message.append("\n第二希望 " + myDataList.get(i).getSecondDayStartDateString().substring(4,6)+"月");
|
||||
message.append(myDataList.get(i).getSecondDayStartDateString().substring(6,8)+"日");
|
||||
message.append(" " + myDataList.get(i).getSecondDayParentStartTimeString().substring(0, 2));
|
||||
message.append(":" + myDataList.get(i).getSecondDayParentStartTimeString().substring(2, 4));
|
||||
message.append("~" + myDataList.get(i).getSecondDayParentEndTimeString().substring(0, 2));
|
||||
message.append(":" + myDataList.get(i).getSecondDayParentEndTimeString().substring(2, 4) + "\n\n");
|
||||
}
|
||||
new AlertDialog.Builder(MainActivity.this)
|
||||
.setTitle("警告")
|
||||
|
@ -307,7 +328,6 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
|||
}
|
||||
|
||||
|
||||
|
||||
//提出状況の取得
|
||||
private ArrayList<SubmissionStudent> getSubmissionStudents() {
|
||||
ArrayList<SubmissionStudent> submissionStudents = new ArrayList<>();
|
||||
|
|
Loading…
Reference in New Issue
Block a user