murakumo_URLコピペボタンの作成完了 #56

Merged
murakumo merged 4 commits from murakumo_URLコピペボタン into master 2024-07-16 05:32:54 +00:00
Showing only changes of commit 98f35c6555 - Show all commits

View File

@ -3,6 +3,7 @@ package com.example.oplogy;
import android.content.ClipData; import android.content.ClipData;
import android.content.ClipboardManager; import android.content.ClipboardManager;
import android.content.Context; import android.content.Context;
import android.app.ProgressDialog;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
@ -29,7 +30,7 @@ import java.util.concurrent.Executors;
public class MainActivity extends AppCompatActivity implements View.OnClickListener { public class MainActivity extends AppCompatActivity implements View.OnClickListener {
private static final String URL_TO_COPY = "https://www.youtube.com/"; private static final String URL_TO_COPY = "https://docs.google.com/forms/d/e/1FAIpQLScKI_ca01nO7die7SqZyThiqa7NB7gcucMJtiV_-sc3eZX6KQ/viewform";
// ダイアログの宣言 // ダイアログの宣言
private AlertDialog alertDialog; private AlertDialog alertDialog;
// ID作成のTextViewとImageView // ID作成のTextViewとImageView
@ -358,6 +359,12 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
} }
private void createRoute(ExecutorService executor) { private void createRoute(ExecutorService executor) {
// ProgressDialogを作成
ProgressDialog progressDialog = new ProgressDialog(MainActivity.this);
progressDialog.setMessage("Loading...");
progressDialog.setCancelable(false);
progressDialog.show();
executor.execute(() -> { executor.execute(() -> {
List<MyDataClass> myDataList = null; List<MyDataClass> myDataList = null;
while (myDataList == null) { while (myDataList == null) {
@ -366,6 +373,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
Thread.sleep(3000); Thread.sleep(3000);
} catch (InterruptedException e) { } catch (InterruptedException e) {
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
runOnUiThread(progressDialog::dismiss); // 進行状況ダイアログを閉じる
return; return;
} }
} }
@ -385,7 +393,9 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
} }
Boolean finalNotDuplicatesBoolean = notDuplicatesBoolean; Boolean finalNotDuplicatesBoolean = notDuplicatesBoolean;
Log.d("MainActivity", "重複判定" + String.valueOf(finalNotDuplicatesBoolean)); Log.d("MainActivity", "重複判定" + String.valueOf(finalNotDuplicatesBoolean));
runOnUiThread(() -> { runOnUiThread(() -> {
progressDialog.dismiss(); // 進行状況ダイアログを閉じる
if (finalNotDuplicatesBoolean) { if (finalNotDuplicatesBoolean) {
Log.d("MainActivity", "スケジュール作成成功"); Log.d("MainActivity", "スケジュール作成成功");
saveMyDataList(finalMyDataList); saveMyDataList(finalMyDataList);
@ -403,6 +413,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
}); });
} }
private void saveMyDataList(List<MyDataClass> myDataList) { private void saveMyDataList(List<MyDataClass> myDataList) {
// 共有プリファレンスのインスタンスを取得 // 共有プリファレンスのインスタンスを取得
SharedPreferences sharedPreferences = getSharedPreferences("MyDataList", MODE_PRIVATE); SharedPreferences sharedPreferences = getSharedPreferences("MyDataList", MODE_PRIVATE);