[Android] Navigation: Fix 'back to root level' behavior

Geoffrey Métais git at videolan.org
Fri Jul 12 14:39:13 CEST 2019


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Jul 12 13:49:01 2019 +0200| [ef6de923ec2571eaf4e45d2a3f71ed7630a7f7f7] | committer: Geoffrey Métais

Navigation: Fix 'back to root level' behavior

> https://code.videolan.org/videolan/vlc-android/commit/ef6de923ec2571eaf4e45d2a3f71ed7630a7f7f7
---

 vlc-android/src/org/videolan/vlc/gui/helpers/Navigator.kt | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/helpers/Navigator.kt b/vlc-android/src/org/videolan/vlc/gui/helpers/Navigator.kt
index 879fdefb3..97acedda6 100644
--- a/vlc-android/src/org/videolan/vlc/gui/helpers/Navigator.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/helpers/Navigator.kt
@@ -30,7 +30,6 @@ import android.view.MenuItem
 import androidx.appcompat.app.ActionBarDrawerToggle
 import androidx.core.view.GravityCompat
 import androidx.fragment.app.Fragment
-import androidx.fragment.app.FragmentActivity
 import androidx.fragment.app.FragmentManager
 import androidx.lifecycle.Lifecycle
 import androidx.lifecycle.LifecycleObserver
@@ -40,6 +39,7 @@ import kotlinx.coroutines.ExperimentalCoroutinesApi
 import kotlinx.coroutines.ObsoleteCoroutinesApi
 import kotlinx.coroutines.delay
 import kotlinx.coroutines.launch
+import org.videolan.tools.isStarted
 import org.videolan.vlc.BuildConfig
 import org.videolan.vlc.R
 import org.videolan.vlc.extensions.ExtensionManagerService
@@ -224,8 +224,8 @@ class Navigator: NavigationView.OnNavigationItemSelectedListener, LifecycleObser
 
             if (currentFragmentId == id) { /* Already selected */
                 // Go back at root level of current mProvider
-                if (current is BaseBrowserFragment && !current.isRootDirectory) {
-                    activity.supportFragmentManager.popBackStackImmediate(getTag(id), FragmentManager.POP_BACK_STACK_INCLUSIVE)
+                if ((current as? BaseBrowserFragment)?.isStarted() == false) {
+                    activity.supportFragmentManager.popBackStackImmediate("root", FragmentManager.POP_BACK_STACK_INCLUSIVE)
                 } else {
                     activity.closeDrawer()
                     return false



More information about the Android mailing list