Przeglądaj źródła

fix: 修复桌面图标回前台保留阅读路由

HapeLee 4 miesięcy temu
rodzic
commit
aa3186d0df

+ 6 - 1
app/src/main/java/io/legado/app/ui/main/MainActivity.kt

@@ -184,6 +184,7 @@ open class MainActivity : BaseComposeActivity(), VariableDialog.Callback {
     override fun onNewIntent(intent: Intent) {
     override fun onNewIntent(intent: Intent) {
         super.onNewIntent(intent)
         super.onNewIntent(intent)
         setIntent(intent)
         setIntent(intent)
+        if (!intent.hasExplicitStartRoute()) return
         routeEvents.tryEmit(MainNavigator.resolveStartRoute(intent))
         routeEvents.tryEmit(MainNavigator.resolveStartRoute(intent))
     }
     }
 
 
@@ -204,7 +205,7 @@ open class MainActivity : BaseComposeActivity(), VariableDialog.Callback {
 
 
         val startRoutes = remember {
         val startRoutes = remember {
             val resolved = MainNavigator.resolveStartRoute(intent)
             val resolved = MainNavigator.resolveStartRoute(intent)
-            val hasExplicitStartRoute = intent?.hasExtra(MainIntent.EXTRA_START_ROUTE) == true
+            val hasExplicitStartRoute = intent?.hasExplicitStartRoute() == true
             when {
             when {
                 !hasExplicitStartRoute && restoredReadBookRoute != null -> {
                 !hasExplicitStartRoute && restoredReadBookRoute != null -> {
                     arrayOf(MainRouteHome, restoredReadBookRoute!!)
                     arrayOf(MainRouteHome, restoredReadBookRoute!!)
@@ -414,6 +415,10 @@ open class MainActivity : BaseComposeActivity(), VariableDialog.Callback {
         )
         )
     }
     }
 
 
+    private fun Intent.hasExplicitStartRoute(): Boolean {
+        return hasExtra(MainIntent.EXTRA_START_ROUTE)
+    }
+
     override fun dispatchKeyEvent(event: KeyEvent): Boolean {
     override fun dispatchKeyEvent(event: KeyEvent): Boolean {
         val keyCode = event.keyCode
         val keyCode = event.keyCode
         val isDown = event.action == KeyEvent.ACTION_DOWN
         val isDown = event.action == KeyEvent.ACTION_DOWN