From 52be2cb8b722bf2e1c2a37cc4bd7e1926be92be3 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Sun, 5 Jun 2022 19:46:56 +0200 Subject: [PATCH] noInternet Activity crash fixed --- app/src/main/java/com/github/libretube/MainActivity.kt | 9 +++++++-- app/src/main/res/layout/activity_nointernet.xml | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/github/libretube/MainActivity.kt b/app/src/main/java/com/github/libretube/MainActivity.kt index 1328a6de1..55b6f3d0e 100644 --- a/app/src/main/java/com/github/libretube/MainActivity.kt +++ b/app/src/main/java/com/github/libretube/MainActivity.kt @@ -282,8 +282,13 @@ class MainActivity : AppCompatActivity() { } } } catch (e: Exception) { - navController.popBackStack() - moveTaskToBack(true) + // try catch to prevent nointernet activity to crash + try { + navController.popBackStack() + moveTaskToBack(true) + } catch (e: Exception){ + super.onBackPressed() + } } } diff --git a/app/src/main/res/layout/activity_nointernet.xml b/app/src/main/res/layout/activity_nointernet.xml index 431d36a3f..9303bc516 100644 --- a/app/src/main/res/layout/activity_nointernet.xml +++ b/app/src/main/res/layout/activity_nointernet.xml @@ -39,6 +39,7 @@ android:layout_height="wrap_content" android:layout_marginTop="10dp" android:text="@string/retry" + android:textColor="?android:attr/colorBackground" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/noInternet_textView" />