バグ修正 #14

Merged
murakumo merged 1 commits from murakumo_uuidのダイアログのバグ修正 into master 2024-06-24 02:11:55 +00:00
Showing only changes of commit f66a9bb8bd - Show all commits

View File

@ -22,6 +22,9 @@ import java.util.concurrent.Executors;
public class MainActivity extends AppCompatActivity implements View.OnClickListener{ public class MainActivity extends AppCompatActivity implements View.OnClickListener{
// ダイアログの宣言
private AlertDialog alertDialog;
// ID作成のTextViewとImageView // ID作成のTextViewとImageView
private TextView creatUUID; private TextView creatUUID;
private ImageView imageUuid; private ImageView imageUuid;
@ -88,12 +91,10 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
if(view == creatUUID){ if(view == creatUUID){
imageUuid.setImageResource(R.drawable.ischecked_uuid); imageUuid.setImageResource(R.drawable.ischecked_uuid);
showUUIDYesNoDialog();//UUIDを表示するかのダイアログ showUUIDYesNoDialog();//UUIDを表示するかのダイアログ
finish(); // 画面遷移後元の状態に戻す
} }
if(view == imageUuid){ if(view == imageUuid){
imageUuid.setImageResource(R.drawable.ischecked_uuid); imageUuid.setImageResource(R.drawable.ischecked_uuid);
showUUIDYesNoDialog();//UUIDを表示するかのダイアログ showUUIDYesNoDialog();//UUIDを表示するかのダイアログ
finish();
} }
// セットアップのクリック処理 // セットアップのクリック処理
if(view == setUp){ if(view == setUp){
@ -171,28 +172,30 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
} }
} }
private void showUUIDYesNoDialog() { private void showUUIDYesNoDialog() {
//ダイアログの表示 AlertDialog.Builder builder = new AlertDialog.Builder(this); // この 'this' が問題でないか確認
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("クラスID"); builder.setTitle("クラスID");
builder.setMessage("あなたのクラスIDを表示しますか"); builder.setMessage("あなたのクラスIDを表示しますか");
//YESのときは初回はUUIDを生成表示
//二回目以降は保存されたUUIDを表示
builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() { builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
String classId = CreateUUID.generateUUID();//classIDにuuidが入ってる String classId = CreateUUID.generateUUID();
Toast.makeText(MainActivity.this, "クラスID: " + classId, Toast.LENGTH_SHORT).show();//テスト用 Toast.makeText(MainActivity.this, "クラスID: " + classId, Toast.LENGTH_SHORT).show();
} }
}); });
builder.setNegativeButton("No", new DialogInterface.OnClickListener() { builder.setNegativeButton("No", new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
Log.d("DialogNO","DialogでNoが選ばれました"); Log.d("DialogNO", "DialogでNoが選ばれました");
} }
}); });
builder.show();
alertDialog = builder.create();
alertDialog.show();
} }
//ルート作成のダイアログ //ルート作成のダイアログ
private void showRouteCreationDialog(CountDownLatch latch) { private void showRouteCreationDialog(CountDownLatch latch) {
new AlertDialog.Builder(MainActivity.this) new AlertDialog.Builder(MainActivity.this)
@ -212,4 +215,13 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
}) })
.show(); .show();
} }
@Override
protected void onDestroy() {
super.onDestroy();
if (alertDialog != null && alertDialog.isShowing()) {
alertDialog.dismiss();
}
}
} }