[Android] Browser: post loading values in main thread

Geoffrey Métais git at videolan.org
Tue Jun 25 10:06:59 CEST 2019


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Jun 25 10:06:30 2019 +0200| [79b21d9eaa4c00a154e75fa9ff268a019e59b8f7] | committer: Geoffrey Métais

Browser: post loading values in main thread

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

 vlc-android/src/org/videolan/vlc/providers/BrowserProvider.kt | 10 +++++-----
 vlc-android/src/org/videolan/vlc/providers/StorageProvider.kt |  2 +-
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/providers/BrowserProvider.kt b/vlc-android/src/org/videolan/vlc/providers/BrowserProvider.kt
index 2d5133fd8..4b3f75b65 100644
--- a/vlc-android/src/org/videolan/vlc/providers/BrowserProvider.kt
+++ b/vlc-android/src/org/videolan/vlc/providers/BrowserProvider.kt
@@ -97,7 +97,7 @@ abstract class BrowserProvider(val context: Context, val dataset: LiveDataset<Me
     }
 
     protected open fun browse(url: String? = null) {
-        loading.value = true
+        loading.postValue(true)
         browserActor.post(Browse(url))
     }
 
@@ -107,14 +107,14 @@ abstract class BrowserProvider(val context: Context, val dataset: LiveDataset<Me
         for (media in browserChannel) findMedia(media)?.let { addMedia(it) }
         if (dataset.value.isNotEmpty()) parseSubDirectories()
         else dataset.clear() // send observable event when folder is empty
-        loading.value = false
+        loading.postValue(false)
     }
 
     protected open fun addMedia(media: MediaLibraryItem) = dataset.add(media)
 
     open fun refresh() {
         if (url === null) return
-        loading.value = true
+        loading.postValue(true)
         browserActor.post(Refresh)
     }
 
@@ -145,7 +145,7 @@ abstract class BrowserProvider(val context: Context, val dataset: LiveDataset<Me
         computeHeaders(value)
         dataset.value = value
         parseSubDirectories()
-        loading.value = false
+        loading.postValue(false)
     }
 
     private suspend fun parseSubDirectoriesImpl() {
@@ -265,7 +265,7 @@ abstract class BrowserProvider(val context: Context, val dataset: LiveDataset<Me
     open fun release() {
         browserActor.post(Release)
         cancel()
-        loading.value = false
+        loading.postValue(false)
     }
 
     protected fun getList(url: String) =  prefetchLists[url]
diff --git a/vlc-android/src/org/videolan/vlc/providers/StorageProvider.kt b/vlc-android/src/org/videolan/vlc/providers/StorageProvider.kt
index 61aa4931d..a6dd9e348 100644
--- a/vlc-android/src/org/videolan/vlc/providers/StorageProvider.kt
+++ b/vlc-android/src/org/videolan/vlc/providers/StorageProvider.kt
@@ -77,7 +77,7 @@ class StorageProvider(context: Context, dataset: LiveDataset<MediaLibraryItem>,
         val value: MutableList<MediaLibraryItem> = browserChannel.filter { it.isStorage() }.mapTo(mutableListOf()) { Storage(it.uri)}
         dataset.value = value
         parseSubDirectories()
-        loading.value = false
+        loading.postValue(false)
     }
 }
 



More information about the Android mailing list