[Android] Fix prefetched navigation
Geoffrey Métais
git at videolan.org
Thu Feb 7 15:26:11 CET 2019
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Feb 7 12:30:15 2019 +0100| [03e21f0cda317cde380db9264f9765240d7c2b57] | committer: Geoffrey Métais
Fix prefetched navigation
> https://code.videolan.org/videolan/vlc-android/commit/03e21f0cda317cde380db9264f9765240d7c2b57
---
vlc-android/src/org/videolan/vlc/providers/BrowserProvider.kt | 4 ++++
vlc-android/src/org/videolan/vlc/providers/NetworkProvider.kt | 7 +++++++
2 files changed, 11 insertions(+)
diff --git a/vlc-android/src/org/videolan/vlc/providers/BrowserProvider.kt b/vlc-android/src/org/videolan/vlc/providers/BrowserProvider.kt
index cb296197f..e4002ad23 100644
--- a/vlc-android/src/org/videolan/vlc/providers/BrowserProvider.kt
+++ b/vlc-android/src/org/videolan/vlc/providers/BrowserProvider.kt
@@ -258,6 +258,10 @@ abstract class BrowserProvider(val context: Context, val dataset: LiveDataset<Me
loading.value = false
}
+ protected fun getList(url: String) = prefetchLists[url]
+
+ protected fun removeList(url: String) = prefetchLists.remove(url)
+
fun saveList(media: MediaWrapper) = foldersContentMap[media]?.let { if (!it.isEmpty()) prefetchLists[media.location] = it }
fun isFolderEmpty(mw: MediaWrapper) = foldersContentMap[mw]?.isEmpty() ?: true
diff --git a/vlc-android/src/org/videolan/vlc/providers/NetworkProvider.kt b/vlc-android/src/org/videolan/vlc/providers/NetworkProvider.kt
index 0456ebfb8..9046b5d12 100644
--- a/vlc-android/src/org/videolan/vlc/providers/NetworkProvider.kt
+++ b/vlc-android/src/org/videolan/vlc/providers/NetworkProvider.kt
@@ -49,13 +49,20 @@ class NetworkProvider(context: Context, dataset: LiveDataset<MediaLibraryItem>,
override fun fetch() {}
override fun refresh(): Boolean {
+ val list by lazy(LazyThreadSafetyMode.NONE) { getList(url!!) }
return if (url == null) {
dataset.value = mutableListOf<MediaLibraryItem>().apply {
getFavoritesList(favorites?.value)?.let { addAll(it) }
}
launch { browseRoot() }
true
+ } else if (list !== null) {
+ dataset.value = list as MutableList<MediaLibraryItem>
+ removeList(url)
+ parseSubDirectories()
+ true
} else super.refresh()
+
}
override fun parseSubDirectories() {
More information about the Android
mailing list