NowLoading作成完了 #54

Merged
murakumo merged 1 commits from murakumo_NowLoading into master 2024-07-16 05:20:05 +00:00
Showing only changes of commit 52a03156a2 - Show all commits

View File

@ -1,5 +1,6 @@
package com.example.oplogy;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
@ -322,6 +323,12 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
}
private void createRoute(ExecutorService executor) {
// ProgressDialogを作成
ProgressDialog progressDialog = new ProgressDialog(MainActivity.this);
progressDialog.setMessage("Loading...");
progressDialog.setCancelable(false);
progressDialog.show();
executor.execute(() -> {
List<MyDataClass> myDataList = null;
while (myDataList == null) {
@ -330,11 +337,11 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
Thread.sleep(3000);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
runOnUiThread(progressDialog::dismiss); // 進行状況ダイアログを閉じる
return;
}
}
//final宣言することによってスレッドセーフになる(ラムダ式内で使えるようにする)
final List<MyDataClass> finalMyDataList = myDataList;
CreateSchedule createSchedule = new CreateSchedule(MainActivity.this);
String startPointLatLngString = createSchedule.receiveData(myDataList, getApplicationContext());
@ -349,7 +356,9 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
}
Boolean finalNotDuplicatesBoolean = notDuplicatesBoolean;
Log.d("MainActivity", "重複判定" + String.valueOf(finalNotDuplicatesBoolean));
runOnUiThread(() -> {
progressDialog.dismiss(); // 進行状況ダイアログを閉じる
if (finalNotDuplicatesBoolean) {
Log.d("MainActivity", "スケジュール作成成功");
saveMyDataList(finalMyDataList);
@ -367,6 +376,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
});
}
private void saveMyDataList(List<MyDataClass> myDataList) {
// 共有プリファレンスのインスタンスを取得
SharedPreferences sharedPreferences = getSharedPreferences("MyDataList", MODE_PRIVATE);