datePicker #30

Merged
murakumo merged 9 commits from datePicker into master 2024-07-03 05:23:34 +00:00
4 changed files with 48 additions and 52 deletions
Showing only changes of commit ca1dca59cc - Show all commits

View File

@ -5,9 +5,8 @@
<option name="linkedExternalProjectsSettings"> <option name="linkedExternalProjectsSettings">
<GradleProjectSettings> <GradleProjectSettings>
<option name="testRunner" value="GRADLE" /> <option name="testRunner" value="GRADLE" />
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" /> <option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleJvm" value="JDK" /> <option name="gradleJvm" value="Embedded JDK" />
<option name="modules"> <option name="modules">
<set> <set>
<option value="$PROJECT_DIR$" /> <option value="$PROJECT_DIR$" />

View File

@ -42,7 +42,7 @@ public class CreateRoot {
private final AppDatabase db; private final AppDatabase db;
private int arraySize; private int arraySize;
boolean Duplicates=true; boolean Duplicates=true;
boolean secondDuplicates=true; boolean secondDuplicates=false;
private Context context; private Context context;
@ -65,7 +65,7 @@ public class CreateRoot {
} }
public Boolean receiveData(List<MyDataClass> myDataList) { public Boolean receiveData(List<MyDataClass> myDataList,Context context) {
//myDataListの要素data第一希望日と第二希望日に以下を追加する //myDataListの要素data第一希望日と第二希望日に以下を追加する
//保護者の希望時間帯の長さ //保護者の希望時間帯の長さ
@ -112,6 +112,8 @@ public class CreateRoot {
if (!Duplicates) { if (!Duplicates) {
sortSchedule(myDataList); sortSchedule(myDataList);
geocodeAddress(myDataList,context);
outPutLogSchedule(myDataList);
} else { } else {
//第二希望日で同じ処理を行う //第二希望日で同じ処理を行う
Log.d("CreateRoot", "第二希望"); Log.d("CreateRoot", "第二希望");
@ -120,20 +122,16 @@ public class CreateRoot {
secondDuplicates = secondCreateSchedule(myDataList, intervalArray); secondDuplicates = secondCreateSchedule(myDataList, intervalArray);
if (!secondDuplicates) { if (!secondDuplicates) {
sortSchedule(myDataList); sortSchedule(myDataList);
geocodeAddress(myDataList,context);
outPutLogSchedule(myDataList);
} else { } else {
Log.d("CreateRoot", "重複によるエラー"); Log.d("CreateRoot", "重複によるエラー");
} }
} }
}); });
if (!secondDuplicates) { return !secondDuplicates;
geocodeAddress(myDataList);
outPutLogSchedule(myDataList);
return true;
} else {
return false;
}
} }
@ -332,9 +330,10 @@ public class CreateRoot {
} }
for (int i = 0; i < myDataList.size(); i++) { for (int i = 0; i < myDataList.size(); i++) {
if (myDataList.get(i).getSchedule() == 0) ; if (myDataList.get(i).getSchedule() == 0) {
return true; return true;
} }
}
return false; return false;
} }
@ -353,6 +352,7 @@ public class CreateRoot {
for (int i = 0; i < myDataList.size(); i++) { for (int i = 0; i < myDataList.size(); i++) {
if (myDataList.get(i).getSchedule() == 0) { if (myDataList.get(i).getSchedule() == 0) {
return true; return true;
} }
} }
return false; return false;
@ -362,7 +362,7 @@ public class CreateRoot {
if (intervalArray[x][j][0] >= Integer.parseInt(myDataList.get(i).getParentStartTimeString()) && intervalArray[x][j + 1][0] <= Integer.parseInt(myDataList.get(i).getParentEndTimeString()) && intervalArray[x][j][1] == 0) { if (intervalArray[x][j][0] >= Integer.parseInt(myDataList.get(i).getParentStartTimeString()) && intervalArray[x][j + 1][0] <= Integer.parseInt(myDataList.get(i).getParentEndTimeString()) && intervalArray[x][j][1] == 0) {
intervalArray[x][j][1] += 1;//割り当て済みを表す intervalArray[x][j][1] += 1;//割り当て済みを表す
myDataList.get(i).setSchedule(Integer.parseInt(desiredDate.substring(4, 8) + String.valueOf(intervalArray[x][j][0]))); myDataList.get(i).setSchedule(Integer.parseInt(desiredDate.substring(4, 8) + intervalArray[x][j][0]));
} }
} }
@ -374,7 +374,7 @@ public class CreateRoot {
private void geocodeAddress(List<MyDataClass> myDataList) { private void geocodeAddress(List<MyDataClass> myDataList,Context context) {
try { try {
Geocoder geocoder = new Geocoder(context, Locale.getDefault()); Geocoder geocoder = new Geocoder(context, Locale.getDefault());
for(int i=0;i<myDataList.size();i++) { for(int i=0;i<myDataList.size();i++) {

View File

@ -40,9 +40,6 @@ public class FirestoreReception {
for (QueryDocumentSnapshot document : task.getResult()) { for (QueryDocumentSnapshot document : task.getResult()) {
Map<String, Object> data = document.getData(); Map<String, Object> data = document.getData();
//CreateRootクラスのインスタンスを生成dataを渡す
// GeoCoder geoCoder = new GeoCoder();
// geoCoder.processData(data, context);
// ドキュメントのデータをMyDataClassのインスタンスにマッピング // ドキュメントのデータをMyDataClassのインスタンスにマッピング
MyDataClass myData = new MyDataClass( MyDataClass myData = new MyDataClass(

View File

@ -48,7 +48,8 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
private FirestoreReception_classIdDatabase firestoreReception_classIdDatabase; private FirestoreReception_classIdDatabase firestoreReception_classIdDatabase;
//取得するためのクラスID //取得するためのクラスID
private int classId=100000; private int classId;
private String address;
@Override @Override
@ -83,10 +84,29 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
// firestoreの受信関連 // firestoreの受信関連
db = FirebaseFirestore.getInstance(); db = FirebaseFirestore.getInstance();
firestoreReception = new FirestoreReception(); firestoreReception = new FirestoreReception();
Log.d("MainActivity","geocodeAddress");
//TODO:classIdの初期値を取得
ExecutorService executor = Executors.newSingleThreadExecutor();
executor.execute(() -> {
try {
AppDatabase db = Room.databaseBuilder(getApplicationContext(), AppDatabase.class, "SetUpTable")
.build();
SetUpTableDao setUpTableDao = db.setUpTableDao();
classId = setUpTableDao.getClassId();
firestoreReception.getDocumentsByClassId(classId);
} catch (Exception e) {
//無視して続行
e.printStackTrace();
}
});
} }
// クリック処理 // クリック処理
@Override @Override
public void onClick(View view) { public void onClick(View view) {
@ -138,10 +158,11 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
startActivity(toSubmission); startActivity(toSubmission);
} }
} }
//UUIDを表示するかのダイアログ //UUIDを表示するかのダイアログ
private void showUUIDYesNoDialog() { private void showUUIDYesNoDialog() {
firestoreReception_classIdDatabase = new FirestoreReception_classIdDatabase(); firestoreReception_classIdDatabase = new FirestoreReception_classIdDatabase();
List<String> classIdList = firestoreReception_classIdDatabase.getAllDocumentsFromClassIdDatabase(); List<Integer> classIdList = firestoreReception_classIdDatabase.getAllDocumentsFromClassIdDatabase();
AlertDialog.Builder builder = new AlertDialog.Builder(this); AlertDialog.Builder builder = new AlertDialog.Builder(this);
@ -207,7 +228,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
} }
Log.d("MainActivity", "myDataList" + myDataList.size()); Log.d("MainActivity", "myDataList" + myDataList.size());
CreateRoot createRoot = new CreateRoot(MainActivity.this); CreateRoot createRoot = new CreateRoot(MainActivity.this);
Boolean notDuplicates = createRoot.receiveData(myDataList); Boolean notDuplicates = createRoot.receiveData(myDataList,getApplicationContext());
latch.countDown(); latch.countDown();
if (notDuplicates) { if (notDuplicates) {
@ -270,12 +291,6 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
.setTitle("警告") .setTitle("警告")
.setMessage(message.toString()) .setMessage(message.toString())
.setPositiveButton("OK", new DialogInterface.OnClickListener() { .setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
latch.countDown();
}
})
.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
dialog.dismiss(); dialog.dismiss();
@ -334,19 +349,4 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
alertDialog.dismiss(); alertDialog.dismiss();
} }
} }
@Override
protected void onResume(){
super.onResume();
//roomからclassIdを取得
ExecutorService executor = Executors.newSingleThreadExecutor();
executor.execute(() -> {
AppDatabase db = Room.databaseBuilder(getApplicationContext(), AppDatabase.class, "SetUpTable").build();
SetUpTableDao setUpTableDao = db.setUpTableDao();
classId = setUpTableDao.getClassId();
});
if (classId != 100000 ) {
firestoreReception.getDocumentsByClassId(classId);
}
}
} }