[Android] Medialibrary folders: update checkboxes on restart

Geoffrey Métais git at videolan.org
Wed Feb 27 11:22:18 CET 2019


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Feb 27 11:21:02 2019 +0100| [b330aabf81acdc597b25880f61a97e11884807c3] | committer: Geoffrey Métais

Medialibrary folders: update checkboxes on restart

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

 .../src/org/videolan/vlc/gui/browser/StorageBrowserAdapter.kt     | 6 ++++++
 .../src/org/videolan/vlc/gui/browser/StorageBrowserFragment.kt    | 8 ++++++--
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/StorageBrowserAdapter.kt b/vlc-android/src/org/videolan/vlc/gui/browser/StorageBrowserAdapter.kt
index 863ffd202..3e5397839 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/StorageBrowserAdapter.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/StorageBrowserAdapter.kt
@@ -72,6 +72,12 @@ internal class StorageBrowserAdapter(fragment: StorageBrowserFragment) : BaseBro
         return false
     }
 
+    suspend fun updateListState(context: Context) {
+        updateMediaDirs(context)
+        job?.join()
+        notifyItemRangeChanged(0, itemCount)
+    }
+
     fun updateMediaDirs(context: Context) {
         mediaDirsLocation.clear()
         val folders = VLCApplication.getMLInstance().foldersList
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 9c6775249..898982730 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/StorageBrowserFragment.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/StorageBrowserFragment.kt
@@ -103,13 +103,17 @@ class StorageBrowserFragment : FileBrowserFragment(), EntryPointsEventsCb {
     override fun onStart() {
         super.onStart()
         VLCApplication.getMLInstance().addEntryPointsEventsCb(this)
-        mSnack?.let { it.show() }
+        mSnack?.show()
+    }
+
+    override fun onRestart() {
+        (adapter as StorageBrowserAdapter).updateListState(requireContext())
     }
 
     override fun onStop() {
         super.onStop()
         VLCApplication.getMLInstance().removeEntryPointsEventsCb(this)
-        mSnack?.let { it.dismiss() }
+        mSnack?.dismiss()
         mAlertDialog?.let { if (it.isShowing) it.dismiss() }
     }
 



More information about the Android mailing list