From 67c2b449eadfa7af7481353645f4e1c018e72b0d Mon Sep 17 00:00:00 2001 From: Li Linfeng Date: Sat, 11 Apr 2020 22:00:07 +0800 Subject: [PATCH] Fix crash caused by clicking menu when loading --- .../java/space/celestia/mobilecelestia/MainActivity.kt | 8 ++++---- .../celestia/mobilecelestia/loading/LoadingFragment.kt | 2 +- .../java/space/celestia/mobilecelestia/utils/String.kt | 3 ++- app/src/main/res/layout/activity_main.xml | 1 + 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/space/celestia/mobilecelestia/MainActivity.kt b/app/src/main/java/space/celestia/mobilecelestia/MainActivity.kt index ff2a2526..c12111b6 100644 --- a/app/src/main/java/space/celestia/mobilecelestia/MainActivity.kt +++ b/app/src/main/java/space/celestia/mobilecelestia/MainActivity.kt @@ -81,7 +81,7 @@ class MainActivity : AppCompatActivity(), private val core by lazy { CelestiaAppCore.shared() } private var currentSelection: CelestiaSelection? = null - private var readyForUriInput = false + private var readyForInteraction = false private var scriptOrURLPath: String? = null @SuppressLint("CheckResult") @@ -164,7 +164,7 @@ class MainActivity : AppCompatActivity(), showWelcomeIfNeeded() // open url/script if present - readyForUriInput = true + readyForInteraction = true runScriptOrOpenURLIfNeeded() } } @@ -269,13 +269,13 @@ class MainActivity : AppCompatActivity(), private fun requestRunScript(path: String) { scriptOrURLPath = path - if (readyForUriInput) + if (readyForInteraction) runScriptOrOpenURLIfNeeded() } private fun requestOpenURL(url: String) { scriptOrURLPath = url - if (readyForUriInput) + if (readyForInteraction) runScriptOrOpenURLIfNeeded() } diff --git a/app/src/main/java/space/celestia/mobilecelestia/loading/LoadingFragment.kt b/app/src/main/java/space/celestia/mobilecelestia/loading/LoadingFragment.kt index 95fb506f..b01ffc0d 100644 --- a/app/src/main/java/space/celestia/mobilecelestia/loading/LoadingFragment.kt +++ b/app/src/main/java/space/celestia/mobilecelestia/loading/LoadingFragment.kt @@ -52,7 +52,7 @@ class LoadingFragment : Fragment(), AppStatusReporter.Listener { companion object { private const val TAG = "LoadingFragment" - public fun newInstance() = LoadingFragment() + fun newInstance() = LoadingFragment() } } diff --git a/app/src/main/java/space/celestia/mobilecelestia/utils/String.kt b/app/src/main/java/space/celestia/mobilecelestia/utils/String.kt index 427d99e1..57ff8b5b 100644 --- a/app/src/main/java/space/celestia/mobilecelestia/utils/String.kt +++ b/app/src/main/java/space/celestia/mobilecelestia/utils/String.kt @@ -2,6 +2,7 @@ package space.celestia.mobilecelestia.utils import space.celestia.mobilecelestia.core.CelestiaAppCore -fun CelestiaString(key: String, comment: String): String { +@Suppress("FunctionName") +fun CelestiaString(key: String, @Suppress("UNUSED_PARAMETER") comment: String): String { return CelestiaAppCore.getLocalizedString(key) } \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 90708d9a..caace44f 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -69,6 +69,7 @@ android:id="@+id/loading_fragment_container" android:layout_width="match_parent" android:layout_height="match_parent" + android:clickable="true" style="@style/Container"/> \ No newline at end of file