[Android] Observe devices & favorites after browseRoot
Geoffrey Métais
git at videolan.org
Thu Aug 9 13:20:06 CEST 2018
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Aug 9 11:37:06 2018 +0200| [39c5c1999730df5f3943ab52967701b7c3354eda] | committer: Geoffrey Métais
Observe devices & favorites after browseRoot
Prevents race condition between storages & favorites
> https://code.videolan.org/videolan/vlc-android/commit/39c5c1999730df5f3943ab52967701b7c3354eda
---
vlc-android/src/org/videolan/vlc/providers/FileBrowserProvider.kt | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/providers/FileBrowserProvider.kt b/vlc-android/src/org/videolan/vlc/providers/FileBrowserProvider.kt
index 165d438e7..69adaf277 100644
--- a/vlc-android/src/org/videolan/vlc/providers/FileBrowserProvider.kt
+++ b/vlc-android/src/org/videolan/vlc/providers/FileBrowserProvider.kt
@@ -36,7 +36,6 @@ import org.videolan.medialibrary.media.MediaLibraryItem
import org.videolan.medialibrary.media.MediaWrapper
import org.videolan.vlc.ExternalMonitor
import org.videolan.vlc.R
-import org.videolan.vlc.database.MediaDatabase
import org.videolan.vlc.database.models.BrowserFav
import org.videolan.vlc.gui.helpers.hf.getDocumentFiles
import org.videolan.vlc.repository.BrowserFavRepository
@@ -88,10 +87,6 @@ open class FileBrowserProvider(
init {
showFavorites = url == null && !filePicker && this !is StorageProvider
- if (url == null) {
- ExternalMonitor.devices.observeForever(this)
- if (showFavorites) favorites?.observeForever(favoritesObserver)
- }
}
override fun browseRoot() {
@@ -123,6 +118,9 @@ open class FileBrowserProvider(
devices.add(otg)
}
dataset.value = devices
+ // observe devices & favorites
+ ExternalMonitor.devices.observeForever(this)
+ if (showFavorites) favorites?.observeForever(favoritesObserver)
}
override fun browse(url: String?) {
More information about the Android
mailing list