myDataListのAddress(住所)をlatlng(緯度経度)に変換する処理の実装
This commit is contained in:
parent
26516e48cf
commit
6a424b234b
|
@ -6,7 +6,7 @@
|
||||||
<GradleProjectSettings>
|
<GradleProjectSettings>
|
||||||
<option name="testRunner" value="GRADLE" />
|
<option name="testRunner" value="GRADLE" />
|
||||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
<option name="gradleJvm" value="#GRADLE_LOCAL_JAVA_HOME" />
|
<option name="gradleJvm" value="Embedded JDK" />
|
||||||
<option name="modules">
|
<option name="modules">
|
||||||
<set>
|
<set>
|
||||||
<option value="$PROJECT_DIR$" />
|
<option value="$PROJECT_DIR$" />
|
||||||
|
|
|
@ -39,18 +39,18 @@ 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;
|
|
||||||
|
|
||||||
String testdata[] = {"20240604", "20240605", "20240606"};
|
|
||||||
|
String[] testdata = {"20240604", "20240605", "20240606"};
|
||||||
|
|
||||||
|
|
||||||
public CreateRoot(AppCompatActivity activity) {
|
public CreateRoot(AppCompatActivity activity) {
|
||||||
this.db = Room.databaseBuilder(activity.getApplicationContext(), AppDatabase.class, "SetUpTable").build();
|
this.db = Room.databaseBuilder(activity.getApplicationContext(), AppDatabase.class, "SetUpTable").build();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean receiveData(List<MyDataClass> myDataList) {
|
public Boolean receiveData(List<MyDataClass> myDataList,Context context) {
|
||||||
|
|
||||||
//myDataListの要素data第一希望日と第二希望日に以下を追加する
|
//myDataListの要素data第一希望日と第二希望日に以下を追加する
|
||||||
//・保護者の希望時間帯の長さ
|
//・保護者の希望時間帯の長さ
|
||||||
|
@ -97,6 +97,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", "第二希望");
|
||||||
|
@ -105,20 +107,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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -317,9 +315,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -338,6 +337,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;
|
||||||
|
@ -347,7 +347,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]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -359,7 +359,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++) {
|
||||||
|
|
|
@ -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(
|
||||||
|
|
|
@ -49,6 +49,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
||||||
|
|
||||||
//取得するためのクラスID
|
//取得するためのクラスID
|
||||||
private int classId;
|
private int classId;
|
||||||
|
private String address;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -83,17 +84,19 @@ 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の初期値を取得
|
//TODO:classIdの初期値を取得
|
||||||
ExecutorService executor = Executors.newSingleThreadExecutor();
|
ExecutorService executor = Executors.newSingleThreadExecutor();
|
||||||
executor.execute(() -> {
|
executor.execute(() -> {
|
||||||
try{
|
try {
|
||||||
AppDatabase db = Room.databaseBuilder(getApplicationContext(), AppDatabase.class, "SetUpTable")
|
AppDatabase db = Room.databaseBuilder(getApplicationContext(), AppDatabase.class, "SetUpTable")
|
||||||
.build();
|
.build();
|
||||||
SetUpTableDao setUpTableDao = db.setUpTableDao();
|
SetUpTableDao setUpTableDao = db.setUpTableDao();
|
||||||
classId = setUpTableDao.getClassId();
|
classId = setUpTableDao.getClassId();
|
||||||
firestoreReception.getDocumentsByClassId(classId);
|
firestoreReception.getDocumentsByClassId(classId);
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
//無視して続行
|
//無視して続行
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -103,29 +106,30 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// クリック処理
|
|
||||||
|
// クリック処理
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
// ID作成のクリック処理
|
// ID作成のクリック処理
|
||||||
if(view == creatUUID){
|
if (view == creatUUID) {
|
||||||
imageUuid.setImageResource(R.drawable.ischecked_uuid);
|
imageUuid.setImageResource(R.drawable.ischecked_uuid);
|
||||||
showUUIDYesNoDialog();//UUIDを表示するかのダイアログ
|
showUUIDYesNoDialog();//UUIDを表示するかのダイアログ
|
||||||
}
|
}
|
||||||
if(view == imageUuid){
|
if (view == imageUuid) {
|
||||||
imageUuid.setImageResource(R.drawable.ischecked_uuid);
|
imageUuid.setImageResource(R.drawable.ischecked_uuid);
|
||||||
showUUIDYesNoDialog();//UUIDを表示するかのダイアログ
|
showUUIDYesNoDialog();//UUIDを表示するかのダイアログ
|
||||||
}
|
}
|
||||||
// セットアップのクリック処理
|
// セットアップのクリック処理
|
||||||
if(view == setUp){
|
if (view == setUp) {
|
||||||
imageSetup.setImageResource(R.drawable.ischecked_uuid);
|
imageSetup.setImageResource(R.drawable.ischecked_uuid);
|
||||||
Intent toSetup = new Intent(MainActivity.this,SetUpActivity.class);
|
Intent toSetup = new Intent(MainActivity.this, SetUpActivity.class);
|
||||||
toSetup.putExtra("classId", classId);
|
toSetup.putExtra("classId", classId);
|
||||||
startActivity(toSetup);
|
startActivity(toSetup);
|
||||||
finish(); // 画面遷移後元の状態に戻す
|
finish(); // 画面遷移後元の状態に戻す
|
||||||
}
|
}
|
||||||
if (view == imageSetup){
|
if (view == imageSetup) {
|
||||||
imageSetup.setImageResource(R.drawable.ischecked_uuid);
|
imageSetup.setImageResource(R.drawable.ischecked_uuid);
|
||||||
Intent toSetup = new Intent(MainActivity.this,SetUpActivity.class);
|
Intent toSetup = new Intent(MainActivity.this, SetUpActivity.class);
|
||||||
startActivity(toSetup);
|
startActivity(toSetup);
|
||||||
finish(); // 画面遷移後元の状態に戻す
|
finish(); // 画面遷移後元の状態に戻す
|
||||||
}
|
}
|
||||||
|
@ -136,12 +140,12 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
||||||
fetchDataAndCreateRoute();
|
fetchDataAndCreateRoute();
|
||||||
|
|
||||||
}
|
}
|
||||||
if(view == imageRoot){
|
if (view == imageRoot) {
|
||||||
imageRoot.setImageResource(R.drawable.pin);
|
imageRoot.setImageResource(R.drawable.pin);
|
||||||
fetchDataAndCreateRoute();
|
fetchDataAndCreateRoute();
|
||||||
}
|
}
|
||||||
// 提出状況のクリック処理
|
// 提出状況のクリック処理
|
||||||
if(view == submission){
|
if (view == submission) {
|
||||||
ArrayList<SubmissionStudent> submissionStudents = getSubmissionStudents();
|
ArrayList<SubmissionStudent> submissionStudents = getSubmissionStudents();
|
||||||
Intent toSubmission = new Intent(MainActivity.this, SubmissionActivity.class);
|
Intent toSubmission = new Intent(MainActivity.this, SubmissionActivity.class);
|
||||||
toSubmission.putParcelableArrayListExtra("submissionStudents", submissionStudents);
|
toSubmission.putParcelableArrayListExtra("submissionStudents", submissionStudents);
|
||||||
|
@ -154,6 +158,7 @@ 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();
|
||||||
|
@ -225,7 +230,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) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user