[Android] Browser: Fix race condition at initial load

Geoffrey Métais git at videolan.org
Mon Jun 24 16:22:26 CEST 2019


vlc-android | branch: 3.1.x | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Jun 24 16:20:43 2019 +0200| [3846dd7ce6034b9e0c033c0d61ae320a1e269bda] | committer: Geoffrey Métais

Browser: Fix race condition at initial load

(cherry picked from commit 7f641671cad06ed956376eb03435ea6f633f4143)

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

 vlc-android/src/org/videolan/vlc/providers/BrowserProvider.kt     | 4 ----
 vlc-android/src/org/videolan/vlc/providers/FileBrowserProvider.kt | 5 +++--
 2 files changed, 3 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 45e6627bf..a1f26cbff 100644
--- a/vlc-android/src/org/videolan/vlc/providers/BrowserProvider.kt
+++ b/vlc-android/src/org/videolan/vlc/providers/BrowserProvider.kt
@@ -72,10 +72,6 @@ abstract class BrowserProvider(val context: Context, val dataset: LiveDataset<Me
         } else channel.close()
     }
 
-    init {
-        fetch()
-    }
-
     protected open fun initBrowser() {
         if (mediabrowser == null) mediabrowser = MediaBrowser(VLCInstance.get(context), this, browserHandler)
     }
diff --git a/vlc-android/src/org/videolan/vlc/providers/FileBrowserProvider.kt b/vlc-android/src/org/videolan/vlc/providers/FileBrowserProvider.kt
index ec8e6da7c..a0d2a7008 100644
--- a/vlc-android/src/org/videolan/vlc/providers/FileBrowserProvider.kt
+++ b/vlc-android/src/org/videolan/vlc/providers/FileBrowserProvider.kt
@@ -56,7 +56,8 @@ open class FileBrowserProvider(
 
     private var storagePosition = -1
     private var otgPosition = -1
-    private val showFavorites : Boolean
+    @Suppress("LeakingThis")
+    private val showFavorites = url == null && !filePicker && this !is StorageProvider
     private val favorites = if (url == null && !filePicker) BrowserFavRepository.getInstance(context).localFavorites else null
 
     private val favoritesObserver by lazy { Observer<List<BrowserFav>> {
@@ -90,7 +91,7 @@ open class FileBrowserProvider(
     } }
 
     init {
-        showFavorites = url == null && !filePicker && this !is StorageProvider
+        fetch()
     }
 
     private lateinit var storageObserver : Observer<Boolean>



More information about the Android mailing list