docking #36
|
@ -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="Embedded JDK" />
|
<option name="gradleJvm" value="jbr-17" />
|
||||||
<option name="modules">
|
<option name="modules">
|
||||||
<set>
|
<set>
|
||||||
<option value="$PROJECT_DIR$" />
|
<option value="$PROJECT_DIR$" />
|
||||||
|
|
|
@ -46,9 +46,6 @@
|
||||||
<activity
|
<activity
|
||||||
android:name=".RootSearchActivity"
|
android:name=".RootSearchActivity"
|
||||||
android:exported="false" />
|
android:exported="false" />
|
||||||
<activity
|
|
||||||
android:name=".CreateUUID"
|
|
||||||
android:exported="false" />
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".DialogFragment"
|
android:name=".DialogFragment"
|
||||||
android:exported="false" />
|
android:exported="false" />
|
||||||
|
|
|
@ -23,7 +23,7 @@ import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
|
|
||||||
//保護者の希望とSetUpActivityによって設定された情報をもとにスケジュールとルートを作成する
|
//保護者の希望とSetUpActivityによって設定された情報をもとにスケジュールとルートを作成する
|
||||||
public class CreateRoot {
|
public class CreateSchedule {
|
||||||
MyDataClass data;//Firestoreから受け取ったdataを入れる変数
|
MyDataClass data;//Firestoreから受け取ったdataを入れる変数
|
||||||
String startTimeHomeVisitString;//家庭訪問の開始時間
|
String startTimeHomeVisitString;//家庭訪問の開始時間
|
||||||
String endTimeHomeVisitString;//家庭訪問の終了時間
|
String endTimeHomeVisitString;//家庭訪問の終了時間
|
||||||
|
@ -43,7 +43,7 @@ public class CreateRoot {
|
||||||
|
|
||||||
String[] testdata = {"20240604", "20240605", "20240606"};
|
String[] testdata = {"20240604", "20240605", "20240606"};
|
||||||
|
|
||||||
public CreateRoot(AppCompatActivity activity) {
|
public CreateSchedule(AppCompatActivity activity) {
|
||||||
this.db = Room.databaseBuilder(activity.getApplicationContext(), AppDatabase.class, "SetUpTable").build();
|
this.db = Room.databaseBuilder(activity.getApplicationContext(), AppDatabase.class, "SetUpTable").build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ public class CreateRoot {
|
||||||
//スケジュールの重複の確認
|
//スケジュールの重複の確認
|
||||||
if (!notDuplicatesBoolean) {
|
if (!notDuplicatesBoolean) {
|
||||||
//第二希望日で同じ処理を行う
|
//第二希望日で同じ処理を行う
|
||||||
Log.d("CreateRoot", "第二希望");
|
Log.d("CreateSchedule", "第二希望");
|
||||||
secondSetData(myDataList);
|
secondSetData(myDataList);
|
||||||
secondTimeZoneSort(myDataList);
|
secondTimeZoneSort(myDataList);
|
||||||
notSecondDuplicatesBoolean = secondCreateSchedule(myDataList, intervalArrayInt);
|
notSecondDuplicatesBoolean = secondCreateSchedule(myDataList, intervalArrayInt);
|
||||||
|
@ -104,7 +104,7 @@ public class CreateRoot {
|
||||||
outPutLogSchedule(myDataList);
|
outPutLogSchedule(myDataList);
|
||||||
return notSecondDuplicatesBoolean;
|
return notSecondDuplicatesBoolean;
|
||||||
}
|
}
|
||||||
Log.d("CreateRoot", "重複によるエラー");
|
Log.d("CreateSchedule", "重複によるエラー");
|
||||||
return !notSecondDuplicatesBoolean;
|
return !notSecondDuplicatesBoolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -211,12 +211,12 @@ public class CreateRoot {
|
||||||
|
|
||||||
private void outPutLogSort(List<MyDataClass> myDataList) {
|
private void outPutLogSort(List<MyDataClass> myDataList) {
|
||||||
for (int i = 0; i < myDataList.size(); i++) {
|
for (int i = 0; i < myDataList.size(); i++) {
|
||||||
Log.d("CreateRoot", "(index: " + i + ") data: " + myDataList.get(i).getPatronName());
|
Log.d("CreateSchedule", "(index: " + i + ") data: " + myDataList.get(i).getPatronName());
|
||||||
Log.d("CreateRoot", "(index: " + i + ") data: " + myDataList.get(i).getClass());
|
Log.d("CreateSchedule", "(index: " + i + ") data: " + myDataList.get(i).getClass());
|
||||||
Log.d("CreateRoot", "(index: " + i + ") timezone: " + myDataList.get(i).getTimezone());
|
Log.d("CreateSchedule", "(index: " + i + ") timezone: " + myDataList.get(i).getTimezone());
|
||||||
Log.d("CreateRoot", "(index: " + i + ") startDate: " + myDataList.get(i).getStartDateString());
|
Log.d("CreateSchedule", "(index: " + i + ") startDate: " + myDataList.get(i).getStartDateString());
|
||||||
Log.d("CreateRoot:outPutLogBeforeSort", "parentStartTimeString: " + myDataList.get(i).getParentStartTimeString());
|
Log.d("CreateSchedule:outPutLogBeforeSort", "parentStartTimeString: " + myDataList.get(i).getParentStartTimeString());
|
||||||
Log.d("CreateRoot:outPutLogBeforeSort", "parentEndTimeString: " + myDataList.get(i).getParentEndTimeString());
|
Log.d("CreateSchedule:outPutLogBeforeSort", "parentEndTimeString: " + myDataList.get(i).getParentEndTimeString());
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -234,11 +234,11 @@ public class CreateRoot {
|
||||||
|
|
||||||
//Roomからのデータ取得に関するログ
|
//Roomからのデータ取得に関するログ
|
||||||
void outPutLogRoomData() {
|
void outPutLogRoomData() {
|
||||||
Log.d("CreateRoot:outPutLogRoomData", "開始時間" + startTimeHomeVisitString);
|
Log.d("CreateSchedule:outPutLogRoomData", "開始時間" + startTimeHomeVisitString);
|
||||||
Log.d("CreateRoot:outPutLogRoomData", "終了時刻" + endTimeHomeVisitString);
|
Log.d("CreateSchedule:outPutLogRoomData", "終了時刻" + endTimeHomeVisitString);
|
||||||
Log.d("CreateRoot:outPutLogRoomData", "一家庭当たりの所要時間" + intervalTimeString);
|
Log.d("CreateSchedule:outPutLogRoomData", "一家庭当たりの所要時間" + intervalTimeString);
|
||||||
Log.d("CreateRoot:outPutLogRoomData", "休憩開始時刻" + startBreakTimeString);
|
Log.d("CreateSchedule:outPutLogRoomData", "休憩開始時刻" + startBreakTimeString);
|
||||||
Log.d("CreateRoot:outPutLogRoomData", "休憩終了時刻" + endBreakTimeString);
|
Log.d("CreateSchedule:outPutLogRoomData", "休憩終了時刻" + endBreakTimeString);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void timeCalculation(String endTimeHomeVisitString, String startBreakTime, String endBreakTime) {
|
private void timeCalculation(String endTimeHomeVisitString, String startBreakTime, String endBreakTime) {
|
||||||
|
@ -284,7 +284,7 @@ public class CreateRoot {
|
||||||
|
|
||||||
private void outPutLogIntervalArray(int[][][] intervalArrayInt) {
|
private void outPutLogIntervalArray(int[][][] intervalArrayInt) {
|
||||||
for (int i = 0; i < intervalArrayInt[0].length; i++) {
|
for (int i = 0; i < intervalArrayInt[0].length; i++) {
|
||||||
Log.d("CreateRoot", "inteintervalArray:(intex:" + i + ") :" + intervalArrayInt[0][i][0]);
|
Log.d("CreateSchedule", "inteintervalArray:(intex:" + i + ") :" + intervalArrayInt[0][i][0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -360,19 +360,19 @@ public class CreateRoot {
|
||||||
double latitudeDouble = addressResult.getLatitude();
|
double latitudeDouble = addressResult.getLatitude();
|
||||||
double longitudeDouble = addressResult.getLongitude();
|
double longitudeDouble = addressResult.getLongitude();
|
||||||
//保護者の住所の緯度経度をmyDataListに追加する
|
//保護者の住所の緯度経度をmyDataListに追加する
|
||||||
myDataList.get(i).setLatLng(new LatLng(latitudeDouble, longitudeDouble));
|
myDataList.get(i).setLatLngString(String.valueOf(new LatLng(latitudeDouble, longitudeDouble)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.e("CreateRoot", "緯度経度の取得に失敗: " + e);
|
Log.e("CreateSchedule", "緯度経度の取得に失敗: " + 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("CreateSchedule:outPutLogSchedule", "(index: " + i + ") data: " + myDataList.get(i));
|
||||||
Log.d("CreateRoot:outPutLogSchedule", "(index: " + i + ") Schedule: " + myDataList.get(i).getSchedule());
|
Log.d("CreateSchedule:outPutLogSchedule", "(index: " + i + ") Schedule: " + myDataList.get(i).getSchedule());
|
||||||
Log.d("CreateRoot", "(index: " + i + ") LatLng" + myDataList.get(i).getLatLng());
|
Log.d("CreateSchedule", "(index: " + i + ") LatLng" + myDataList.get(i).getLatLngString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -2,18 +2,19 @@ package com.example.oplogy;
|
||||||
|
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import androidx.room.Room;
|
import androidx.room.Room;
|
||||||
|
|
||||||
import com.google.firebase.firestore.FirebaseFirestore;
|
import com.google.firebase.firestore.FirebaseFirestore;
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -87,6 +88,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
||||||
Log.d("MainActivity", "geocodeAddress");
|
Log.d("MainActivity", "geocodeAddress");
|
||||||
|
|
||||||
|
|
||||||
|
//TODO:classIdの初期値を取得
|
||||||
ExecutorService executor = Executors.newSingleThreadExecutor();
|
ExecutorService executor = Executors.newSingleThreadExecutor();
|
||||||
executor.execute(() -> {
|
executor.execute(() -> {
|
||||||
try {
|
try {
|
||||||
|
@ -274,12 +276,13 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
||||||
|
|
||||||
//final宣言することによって、スレッドセーフになる(ラムダ式内で使えるようにする)
|
//final宣言することによって、スレッドセーフになる(ラムダ式内で使えるようにする)
|
||||||
final List<MyDataClass> finalMyDataList = myDataList;
|
final List<MyDataClass> finalMyDataList = myDataList;
|
||||||
CreateRoot createRoot = new CreateRoot(MainActivity.this);
|
CreateSchedule createSchedule = new CreateSchedule(MainActivity.this);
|
||||||
Boolean notDuplicates = createRoot.receiveData(finalMyDataList, getApplicationContext());
|
Boolean notDuplicates = createSchedule.receiveData(myDataList, getApplicationContext());
|
||||||
|
|
||||||
runOnUiThread(() -> {
|
runOnUiThread(() -> {
|
||||||
if (notDuplicates) {
|
if (notDuplicates) {
|
||||||
Log.d("MainActivity", "スケジュール作成成功");
|
Log.d("MainActivity", "スケジュール作成成功");
|
||||||
|
saveMyDataList(finalMyDataList);
|
||||||
Intent toRoot = new Intent(MainActivity.this, Maps.class);
|
Intent toRoot = new Intent(MainActivity.this, Maps.class);
|
||||||
startActivity(toRoot);
|
startActivity(toRoot);
|
||||||
} else {
|
} else {
|
||||||
|
@ -292,6 +295,19 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
||||||
executor.shutdown();
|
executor.shutdown();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
private void saveMyDataList(List<MyDataClass> myDataList) {
|
||||||
|
// 共有プリファレンスのインスタンスを取得
|
||||||
|
SharedPreferences sharedPreferences = getSharedPreferences("MyDataList", MODE_PRIVATE);
|
||||||
|
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||||
|
|
||||||
|
// MyDataListをJSON形式に変換
|
||||||
|
Gson gson = new Gson();
|
||||||
|
String json = gson.toJson(myDataList);
|
||||||
|
|
||||||
|
// JSON形式のデータを共有プリファレンスに保存
|
||||||
|
editor.putString("myDataList", json);
|
||||||
|
editor.apply();
|
||||||
|
}
|
||||||
|
|
||||||
private void showErrorDialog(List<MyDataClass> myDataList) {
|
private void showErrorDialog(List<MyDataClass> myDataList) {
|
||||||
List<Integer> studentNumbers = new ArrayList<>();
|
List<Integer> studentNumbers = new ArrayList<>();
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
package com.example.oplogy;
|
package com.example.oplogy;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.Parcelable;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.webkit.WebSettings;
|
import android.webkit.WebSettings;
|
||||||
import android.webkit.WebView;
|
import android.webkit.WebView;
|
||||||
|
@ -11,13 +14,19 @@ import android.widget.ImageView;
|
||||||
import androidx.fragment.app.FragmentActivity;
|
import androidx.fragment.app.FragmentActivity;
|
||||||
|
|
||||||
import com.example.oplogy.databinding.MapsBinding;
|
import com.example.oplogy.databinding.MapsBinding;
|
||||||
|
import com.google.common.reflect.TypeToken;
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
|
||||||
|
import java.lang.reflect.Type;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class Maps extends FragmentActivity implements View.OnClickListener {
|
public class Maps extends FragmentActivity implements View.OnClickListener {
|
||||||
|
|
||||||
private WebView webView;
|
private WebView webView;
|
||||||
ImageView backMain;
|
ImageView backMain;
|
||||||
private MapsBinding binding;
|
private MapsBinding binding;
|
||||||
|
private ArrayList<Parcelable> myDataList;;
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
@ -32,9 +41,36 @@ public class Maps extends FragmentActivity implements View.OnClickListener {
|
||||||
WebSettings webSettings = webView.getSettings();
|
WebSettings webSettings = webView.getSettings();
|
||||||
webSettings.setJavaScriptEnabled(true);
|
webSettings.setJavaScriptEnabled(true);
|
||||||
webView.setWebViewClient(new WebViewClient());
|
webView.setWebViewClient(new WebViewClient());
|
||||||
|
List<MyDataClass> myDataList=getMyDataList();
|
||||||
|
String latlngString = "";
|
||||||
|
for (int i = 0; i < myDataList.size(); i++) {
|
||||||
|
String latlng = myDataList.get(i).getLatLngString();
|
||||||
|
int startIndex = latlng.indexOf("(") + 1;
|
||||||
|
int endIndex = latlng.indexOf(")");
|
||||||
|
String latlngOnly = latlng.substring(startIndex, endIndex);
|
||||||
|
latlngString += latlngOnly;
|
||||||
|
if (i < myDataList.size() - 1) {
|
||||||
|
latlngString += "/";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Log.d("Maps","latlngString"+latlngString);
|
||||||
|
loadMapInWebView(latlngString);
|
||||||
|
}
|
||||||
|
|
||||||
// ここにデータを入れておいてください、処理は[/]で区切っています
|
// 共有プリファレンスからMyDataListを取得するメソッド
|
||||||
loadMapInWebView("35.09050879999539,136.87845379325216/35.09284820618655,136.88165119390393/35.09364708442631,136.88171563326418");
|
private List<MyDataClass> getMyDataList() {
|
||||||
|
// 共有プリファレンスのインスタンスを取得
|
||||||
|
SharedPreferences sharedPreferences = getSharedPreferences("MyDataList", MODE_PRIVATE);
|
||||||
|
|
||||||
|
// 共有プリファレンスからJSON形式のデータを取得
|
||||||
|
String json = sharedPreferences.getString("myDataList", "");
|
||||||
|
|
||||||
|
// JSON形式のデータをMyDataListに変換
|
||||||
|
Gson gson = new Gson();
|
||||||
|
Type type = new TypeToken<List<MyDataClass>>() {}.getType();
|
||||||
|
List<MyDataClass> myDataList = gson.fromJson(json, type);
|
||||||
|
|
||||||
|
return myDataList;
|
||||||
}
|
}
|
||||||
|
|
||||||
// WebViewの処理です(Mapの中の処理をやっています)
|
// WebViewの処理です(Mapの中の処理をやっています)
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
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;
|
||||||
|
@ -30,7 +29,7 @@ public class MyDataClass {
|
||||||
private Long secondDayTimezoneLong;
|
private Long secondDayTimezoneLong;
|
||||||
private String secondDayParentStartTimeString;
|
private String secondDayParentStartTimeString;
|
||||||
private String secondDayParentEndTimeString;
|
private String secondDayParentEndTimeString;
|
||||||
private LatLng latLng;
|
private String latLngString;
|
||||||
|
|
||||||
|
|
||||||
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) {
|
||||||
|
@ -239,11 +238,11 @@ public class MyDataClass {
|
||||||
return secondDayStartDateString;
|
return secondDayStartDateString;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLatLng(LatLng latLng) {
|
public void setLatLngString(String latLng) {
|
||||||
this.latLng=latLng;
|
this.latLngString=latLng;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LatLng getLatLng() {
|
public String getLatLngString() {
|
||||||
return latLng;
|
return latLngString;
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user