From 1eea70f92019ab2b46465cf29e9fbd25aac29211 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Wed, 17 Jan 2024 19:15:24 +0900 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/example/childguard/MainActivity.java | 27 +++++++++---------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/com/example/childguard/MainActivity.java b/app/src/main/java/com/example/childguard/MainActivity.java index a1121df..ccac9c0 100644 --- a/app/src/main/java/com/example/childguard/MainActivity.java +++ b/app/src/main/java/com/example/childguard/MainActivity.java @@ -160,21 +160,16 @@ public class MainActivity extends AppCompatActivity { @Override protected void onResume() { Log.d("onResume", "called"); - if (mDocRef == null) { - Log.d("onResume", "mDocRef is null"); - SharedPreferences sharedPreferences = getSharedPreferences("app_situation", MODE_PRIVATE); - String IdPref = sharedPreferences.getString("ID", null); - if (IdPref == null) { - Log.d("onResume", "ID not initialized."); - return; - } - mDocRef = FirebaseFirestore.getInstance().document("users/" + IdPref);//現在の位置を取得 - initNotification(mDocRef); - } - - if (mDocRef.getId().equals(null)) { - Log.d("onResume", "mDocRef.getId() is null"); + Log.d("onResume", "mDocRef is null"); + SharedPreferences sharedPreferences = getSharedPreferences("app_situation", MODE_PRIVATE); + String IdPref = sharedPreferences.getString("ID", null); + if (IdPref == null) { + Log.d("onResume", "ID not initialized."); + return; } + mDocRef = FirebaseFirestore.getInstance().document("users/" + IdPref);//現在の位置を取得 + this.flg = false; + initNotification(mDocRef); super.onResume(); } @@ -218,7 +213,9 @@ public class MainActivity extends AppCompatActivity { // SupportFragmentManagerが現在表示しているFragmentを取得 Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.fragmentContainerView); if (fragment instanceof HomeFragment) { - ((HomeFragment) fragment).updateUiState(!isInCar); + ((HomeFragment) fragment).onEvent(!isInCar); + } else { + Log.d("nt", "HomeFragment is not visible"); } } }