[Android] Browser: prevent IllegalStateException

Geoffrey Métais git at videolan.org
Tue Oct 15 10:52:28 CEST 2019


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Oct 15 10:52:07 2019 +0200| [c414eb1e4245438f7e41b52a0584595904dfe39c] | committer: Geoffrey Métais

Browser: prevent IllegalStateException

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

 vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.kt | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.kt b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.kt
index 89cc45984..6f01574e2 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.kt
@@ -33,6 +33,7 @@ import androidx.appcompat.view.ActionMode
 import androidx.core.content.ContextCompat
 import androidx.fragment.app.Fragment
 import androidx.fragment.app.FragmentManager
+import androidx.lifecycle.Lifecycle
 import androidx.lifecycle.Observer
 import androidx.recyclerview.widget.DividerItemDecoration
 import androidx.recyclerview.widget.LinearLayoutManager
@@ -244,6 +245,7 @@ abstract class BaseBrowserFragment : MediaBrowserFragment<BrowserModel>(), IRefr
 
     fun goBack(): Boolean {
         val activity = activity ?: return false
+        if (!activity.lifecycle.currentState.isAtLeast(Lifecycle.State.RESUMED)) return false
         if (!isRootDirectory && !activity.isFinishing && !activity.isDestroyed) activity.supportFragmentManager.popBackStack()
         return !isRootDirectory
     }



More information about the Android mailing list