[Android] StorageBrowser: Prevent IllegalStateException
Geoffrey Métais
git at videolan.org
Fri Mar 1 18:21:43 CET 2019
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Mar 1 15:56:52 2019 +0100| [5f94a252e810c362a95a627be38ca1e60a06b96d] | committer: Geoffrey Métais
StorageBrowser: Prevent IllegalStateException
> https://code.videolan.org/videolan/vlc-android/commit/5f94a252e810c362a95a627be38ca1e60a06b96d
---
.../src/org/videolan/vlc/gui/browser/StorageBrowserFragment.kt | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/StorageBrowserFragment.kt b/vlc-android/src/org/videolan/vlc/gui/browser/StorageBrowserFragment.kt
index a0b588c3e..a1346cd27 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/StorageBrowserFragment.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/StorageBrowserFragment.kt
@@ -106,7 +106,7 @@ class StorageBrowserFragment : FileBrowserFragment(), EntryPointsEventsCb, Corou
}
override fun onRestart() {
- launch { (adapter as StorageBrowserAdapter).updateListState(requireContext()) }
+ launch { if (isAdded) (adapter as StorageBrowserAdapter).updateListState(requireContext()) }
}
override fun onStop() {
@@ -151,9 +151,9 @@ class StorageBrowserFragment : FileBrowserFragment(), EntryPointsEventsCb, Corou
override fun onCtxClick(v: View, position: Int, item: MediaLibraryItem) {
if (isRootDirectory) {
val storage = adapter.getItem(position) as Storage
- coroutineScope.launch {
+ launch {
val isCustom = viewModel.customDirectoryExists(storage.uri.path)
- if (isCustom) showContext(requireActivity(), this at StorageBrowserFragment, position, item.title, CTX_CUSTOM_REMOVE)
+ if (isCustom && isAdded) showContext(requireActivity(), this at StorageBrowserFragment, position, item.title, CTX_CUSTOM_REMOVE)
}
}
}
More information about the Android
mailing list