[Android] Multiselect helper crash fixes

Nicolas Pomepuy git at videolan.org
Fri Aug 2 14:35:38 CEST 2019


vlc-android | branch: master | Nicolas Pomepuy <nicolas.pomepuy at gmail.com> | Thu Aug  1 07:25:19 2019 +0200| [fd690bda5fba7f61a8a3cf40b9a057e95b637cad] | committer: Nicolas Pomepuy

Multiselect helper crash fixes

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

 vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.kt | 2 +-
 vlc-android/src/org/videolan/vlc/gui/folders/FoldersFragment.kt     | 2 +-
 vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.kt     | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

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 27ad6b923..8fc7083eb 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.kt
@@ -193,7 +193,7 @@ abstract class BaseBrowserFragment : MediaBrowserFragment<BrowserModel>(), IRefr
         else -> mrl ?: ""
     }
 
-    override fun getMultiHelper(): MultiSelectHelper<BrowserModel>? = adapter.multiSelectHelper as? MultiSelectHelper<BrowserModel>
+    override fun getMultiHelper(): MultiSelectHelper<BrowserModel>? = if (::adapter.isInitialized) adapter.multiSelectHelper as? MultiSelectHelper<BrowserModel> else null
 
     override val subTitle: String? =
             if (isRootDirectory) null else {
diff --git a/vlc-android/src/org/videolan/vlc/gui/folders/FoldersFragment.kt b/vlc-android/src/org/videolan/vlc/gui/folders/FoldersFragment.kt
index 579c6c3b8..a4955626a 100644
--- a/vlc-android/src/org/videolan/vlc/gui/folders/FoldersFragment.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/folders/FoldersFragment.kt
@@ -90,7 +90,7 @@ class FoldersFragment : MediaBrowserFragment<FoldersViewModel>(), CtxActionRecei
 
     override fun getTitle(): String = getString(R.string.video)
 
-    override fun getMultiHelper(): MultiSelectHelper<FoldersViewModel>? = adapter.multiSelectHelper as? MultiSelectHelper<FoldersViewModel>
+    override fun getMultiHelper(): MultiSelectHelper<FoldersViewModel>? = if (::adapter.isInitialized) adapter.multiSelectHelper as? MultiSelectHelper<FoldersViewModel> else null
 
     override fun onRefresh() = viewModel.refresh()
 
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.kt b/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.kt
index 3fad0b470..a7751e575 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.kt
@@ -190,7 +190,7 @@ class VideoGridFragment : MediaBrowserFragment<VideosViewModel>(), SwipeRefreshL
 
     override fun getTitle() = viewModel.folder?.title ?: getString(R.string.video)
 
-    override fun getMultiHelper(): MultiSelectHelper<VideosViewModel>? = videoListAdapter.multiSelectHelper as? MultiSelectHelper<VideosViewModel>
+    override fun getMultiHelper(): MultiSelectHelper<VideosViewModel>? = if (::videoListAdapter.isInitialized) videoListAdapter.multiSelectHelper as? MultiSelectHelper<VideosViewModel> else null
 
     private fun updateViewMode() {
         if (view == null || activity == null) {



More information about the Android mailing list