[Android] Browser: prevent IllegalStateException
Geoffrey Métais
git at videolan.org
Tue Oct 15 10:56:18 CEST 2019
vlc-android | branch: 3.2.x | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Oct 15 10:52:07 2019 +0200| [543784743034edc82a7d483fce0ff0c83a606f25] | committer: Geoffrey Métais
Browser: prevent IllegalStateException
(cherry picked from commit c414eb1e4245438f7e41b52a0584595904dfe39c)
> https://code.videolan.org/videolan/vlc-android/commit/543784743034edc82a7d483fce0ff0c83a606f25
---
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 3d2ba8c4b..10450b0cf 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.kt
@@ -32,6 +32,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
@@ -208,6 +209,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