[Android] Fix crash on empty view when fragment is not attached

Nicolas Pomepuy git at videolan.org
Wed May 18 08:17:48 UTC 2022


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Wed May 18 09:39:14 2022 +0200| [414d324bcc93addbfb694d00c918b6f22fe9f4c4] | committer: Nicolas Pomepuy

Fix crash on empty view when fragment is not attached

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

 .../vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.kt      | 1 +
 1 file changed, 1 insertion(+)

diff --git a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.kt b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.kt
index 7f4aa9a43..834cf1205 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.kt
@@ -304,6 +304,7 @@ class VideoGridFragment : MediaBrowserFragment<VideosViewModel>(), SwipeRefreshL
 
     private fun updateEmptyView() {
         if (!::binding.isInitialized) return
+        if (!isAdded) return
         val empty = viewModel.isEmpty() && videoListAdapter.currentList.isNullOrEmpty()
         val working = viewModel.provider.loading.value != false
         binding.emptyLoading.emptyText = viewModel.filterQuery?.let {  getString(R.string.empty_search, it) } ?: getString(R.string.nomedia)



More information about the Android mailing list