[Android] Browser: Fix race condition at initial load

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


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

Browser: Fix race condition at initial load

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

 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 19c87b64e..2d5133fd8 100644
--- a/vlc-android/src/org/videolan/vlc/providers/BrowserProvider.kt
+++ b/vlc-android/src/org/videolan/vlc/providers/BrowserProvider.kt
@@ -76,10 +76,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 2840397de..0b12c2777 100644
--- a/vlc-android/src/org/videolan/vlc/providers/FileBrowserProvider.kt
+++ b/vlc-android/src/org/videolan/vlc/providers/FileBrowserProvider.kt
@@ -55,7 +55,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>> {
@@ -88,7 +89,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