DatePickを使用して、SetUpに入れる機能が完成しました。SharedPreferencesにも保存しました。
追記:バグとり完了
This commit is contained in:
commit
6380263dfc
|
@ -1,5 +1,8 @@
|
||||||
package com.example.oplogy;
|
package com.example.oplogy;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.location.Address;
|
||||||
|
import android.location.Geocoder;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
@ -7,13 +10,17 @@ import android.util.Log;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import androidx.room.Room;
|
import androidx.room.Room;
|
||||||
|
|
||||||
|
import com.google.android.gms.maps.model.LatLng;
|
||||||
|
import com.google.android.gms.maps.model.LatLng;
|
||||||
import com.google.firebase.Timestamp;
|
import com.google.firebase.Timestamp;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
|
@ -34,8 +41,10 @@ public class CreateRoot {
|
||||||
|
|
||||||
private final AppDatabase db;
|
private final AppDatabase db;
|
||||||
private int arraySize;
|
private int arraySize;
|
||||||
|
boolean Duplicates=true;
|
||||||
|
boolean secondDuplicates=true;
|
||||||
|
|
||||||
boolean secondDuplicates;
|
private Context context;
|
||||||
|
|
||||||
// String testdata[] = {"20240604", "20240605", "20240606"};
|
// String testdata[] = {"20240604", "20240605", "20240606"};
|
||||||
String[] testdata;
|
String[] testdata;
|
||||||
|
@ -97,12 +106,12 @@ public class CreateRoot {
|
||||||
|
|
||||||
outPutLogIntervalArray(intervalArray);
|
outPutLogIntervalArray(intervalArray);
|
||||||
//スケジュール作成
|
//スケジュール作成
|
||||||
boolean Duplicates = createSchedule(myDataList, intervalArray);
|
Duplicates = createSchedule(myDataList, intervalArray);
|
||||||
|
|
||||||
//重複によるエラー確認
|
//重複によるエラー確認
|
||||||
if (!Duplicates) {
|
if (!Duplicates) {
|
||||||
sortSchedule(myDataList);
|
sortSchedule(myDataList);
|
||||||
outPutLogSchedule(myDataList);
|
|
||||||
} else {
|
} else {
|
||||||
//第二希望日で同じ処理を行う
|
//第二希望日で同じ処理を行う
|
||||||
Log.d("CreateRoot", "第二希望");
|
Log.d("CreateRoot", "第二希望");
|
||||||
|
@ -111,13 +120,16 @@ public class CreateRoot {
|
||||||
secondDuplicates = secondCreateSchedule(myDataList, intervalArray);
|
secondDuplicates = secondCreateSchedule(myDataList, intervalArray);
|
||||||
if (!secondDuplicates) {
|
if (!secondDuplicates) {
|
||||||
sortSchedule(myDataList);
|
sortSchedule(myDataList);
|
||||||
outPutLogSchedule(myDataList);
|
|
||||||
} else {
|
} else {
|
||||||
Log.d("CreateRoot", "重複によるエラー");
|
Log.d("CreateRoot", "重複によるエラー");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!secondDuplicates) {
|
if (!secondDuplicates) {
|
||||||
|
geocodeAddress(myDataList);
|
||||||
|
outPutLogSchedule(myDataList);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
@ -360,12 +372,30 @@ public class CreateRoot {
|
||||||
myDataList.sort(comparator);
|
myDataList.sort(comparator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void geocodeAddress(List<MyDataClass> myDataList) {
|
||||||
|
try {
|
||||||
|
Geocoder geocoder = new Geocoder(context, Locale.getDefault());
|
||||||
|
for(int i=0;i<myDataList.size();i++) {
|
||||||
|
List<Address> addresses = geocoder.getFromLocationName(myDataList.get(i).getAddress().toString(), 1);
|
||||||
|
if (addresses != null && !addresses.isEmpty()) {
|
||||||
|
Address addressResult = addresses.get(0);
|
||||||
|
double latitude = addressResult.getLatitude();
|
||||||
|
double longitude = addressResult.getLongitude();
|
||||||
|
myDataList.get(i).setLatLng(new LatLng(latitude, longitude));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
Log.e("CreateRoot", "緯度経度の取得に失敗: " +e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void outPutLogSchedule(List<MyDataClass> myDataList) {
|
private void outPutLogSchedule(List<MyDataClass> myDataList) {
|
||||||
for (int i = 0; i < myDataList.size(); i++) {
|
for (int i = 0; i < myDataList.size(); i++) {
|
||||||
Log.d("CreateRoot:outPutLogSchedule", "(index: " + i + ") data: " + myDataList.get(i));
|
Log.d("CreateRoot:outPutLogSchedule", "(index: " + i + ") data: " + myDataList.get(i));
|
||||||
Log.d("CreateRoot:outPutLogSchedule", "(index: " + i + ") Schedule: " + myDataList.get(i).getSchedule());
|
Log.d("CreateRoot:outPutLogSchedule", "(index: " + i + ") Schedule: " + myDataList.get(i).getSchedule());
|
||||||
Log.d("CreateRoot:outPutLogSchedule", "(index: " + i + ") date: " + myDataList.get(i).getStartDateString());
|
Log.d("CreateRoot","(index: " + i + ") LatLng"+myDataList.get(i).getLatLng());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
package com.example.oplogy;
|
package com.example.oplogy;
|
||||||
|
|
||||||
|
import com.google.android.gms.maps.model.LatLng;
|
||||||
import com.google.firebase.Timestamp;
|
import com.google.firebase.Timestamp;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class MyDataClass {
|
public class MyDataClass {
|
||||||
|
|
||||||
String patronName;
|
String patronName;
|
||||||
int classId;
|
int classId;
|
||||||
List<String> address;
|
List<String> address;
|
||||||
|
@ -28,6 +30,7 @@ public class MyDataClass {
|
||||||
private Long secondDayTimezone;
|
private Long secondDayTimezone;
|
||||||
private String secondDayParentStartTimeString;
|
private String secondDayParentStartTimeString;
|
||||||
private String secondDayParentEndTimeString;
|
private String secondDayParentEndTimeString;
|
||||||
|
private LatLng latLng;
|
||||||
|
|
||||||
|
|
||||||
public MyDataClass(String patronName, int classId, List<String> address, List<Timestamp> firstDay, int studentNumber, String childName, List<Timestamp> thirdDay, List<Timestamp> secondDay) {
|
public MyDataClass(String patronName, int classId, List<String> address, List<Timestamp> firstDay, int studentNumber, String childName, List<Timestamp> thirdDay, List<Timestamp> secondDay) {
|
||||||
|
@ -235,4 +238,12 @@ public class MyDataClass {
|
||||||
public String getSecondDayStartDateString() {
|
public String getSecondDayStartDateString() {
|
||||||
return secondDayStartDateString;
|
return secondDayStartDateString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setLatLng(LatLng latLng) {
|
||||||
|
this.latLng=latLng;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LatLng getLatLng() {
|
||||||
|
return latLng;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -141,11 +141,8 @@ public class SetUpActivity extends FragmentActivity
|
||||||
|
|
||||||
executor.execute(() -> {
|
executor.execute(() -> {
|
||||||
//roomのインスタンスを作成
|
//roomのインスタンスを作成
|
||||||
AppDatabase db = Room.databaseBuilder(
|
AppDatabase db = Room.databaseBuilder(getApplicationContext(), AppDatabase.class, "SetUpTable")
|
||||||
getApplicationContext(),
|
.fallbackToDestructiveMigration()
|
||||||
AppDatabase.class,
|
|
||||||
"SetUpTable"
|
|
||||||
)
|
|
||||||
.build();
|
.build();
|
||||||
SetUpTableDao setUpTableDao = db.setUpTableDao();
|
SetUpTableDao setUpTableDao = db.setUpTableDao();
|
||||||
// Roomの操作を行う
|
// Roomの操作を行う
|
||||||
|
|
Loading…
Reference in New Issue
Block a user