From 725d541316b082b387effa247963dcce82d97561 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Fri, 19 Jan 2024 15:14:08 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=AA=E3=83=95=E3=82=A1=E3=82=AF=E3=82=BF?= =?UTF-8?q?=E3=83=AA=E3=83=B3=E3=82=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/one/nem/lacerta/MainActivity.java | 28 +++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/one/nem/lacerta/MainActivity.java b/app/src/main/java/one/nem/lacerta/MainActivity.java index b1d68a43..f1fa4676 100644 --- a/app/src/main/java/one/nem/lacerta/MainActivity.java +++ b/app/src/main/java/one/nem/lacerta/MainActivity.java @@ -9,6 +9,7 @@ import androidx.navigation.ui.NavigationUI; import android.graphics.Color; import android.os.Bundle; +import android.util.Log; import android.widget.Toast; import com.google.android.material.bottomnavigation.BottomNavigationView; @@ -27,18 +28,23 @@ public class MainActivity extends AppCompatActivity { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); - // Debug - FragmentManager supportFragmentManager = getSupportFragmentManager(); - - NavHostFragment navHostFragment = (NavHostFragment) supportFragmentManager.findFragmentById(R.id.nav_host_fragment); - NavController navController = navHostFragment.getNavController(); - BottomNavigationView bottomNavigationView = findViewById(R.id.bottom_nav); - - NavigationUI.setupWithNavController(bottomNavigationView, navController); + // Init navigation + try { + FragmentManager supportFragmentManager = getSupportFragmentManager(); + NavHostFragment navHostFragment = (NavHostFragment) supportFragmentManager.findFragmentById(R.id.nav_host_fragment); + assert navHostFragment != null; + NavController navController = navHostFragment.getNavController(); + BottomNavigationView bottomNavigationView = findViewById(R.id.bottom_nav); + NavigationUI.setupWithNavController(bottomNavigationView, navController); + } + catch (Exception e) { + Log.e("Init", "Failed to init navigation"); + Log.e("Init", "Searchable Error code: " + "894b5941-3bc0-46fe-b752-0dbc88be29a8"); + Toast.makeText(this, "Failed to init navigation", Toast.LENGTH_LONG).show(); + finish(); // Exit app + } + // Set navigation bar color getWindow().setNavigationBarColor(ContextCompat.getColor(this, one.nem.lacerta.shared.ui.R.color.colorSurfaceVariant)); - - } - }