Commit 03e21f0c authored by Geoffrey Métais's avatar Geoffrey Métais

Fix prefetched navigation

parent d14b4bd4
...@@ -258,6 +258,10 @@ abstract class BrowserProvider(val context: Context, val dataset: LiveDataset<Me ...@@ -258,6 +258,10 @@ abstract class BrowserProvider(val context: Context, val dataset: LiveDataset<Me
loading.value = false 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 saveList(media: MediaWrapper) = foldersContentMap[media]?.let { if (!it.isEmpty()) prefetchLists[media.location] = it }
fun isFolderEmpty(mw: MediaWrapper) = foldersContentMap[mw]?.isEmpty() ?: true fun isFolderEmpty(mw: MediaWrapper) = foldersContentMap[mw]?.isEmpty() ?: true
......
...@@ -49,13 +49,20 @@ class NetworkProvider(context: Context, dataset: LiveDataset<MediaLibraryItem>, ...@@ -49,13 +49,20 @@ class NetworkProvider(context: Context, dataset: LiveDataset<MediaLibraryItem>,
override fun fetch() {} override fun fetch() {}
override fun refresh(): Boolean { override fun refresh(): Boolean {
val list by lazy(LazyThreadSafetyMode.NONE) { getList(url!!) }
return if (url == null) { return if (url == null) {
dataset.value = mutableListOf<MediaLibraryItem>().apply { dataset.value = mutableListOf<MediaLibraryItem>().apply {
getFavoritesList(favorites?.value)?.let { addAll(it) } getFavoritesList(favorites?.value)?.let { addAll(it) }
} }
launch { browseRoot() } launch { browseRoot() }
true true
} else if (list !== null) {
dataset.value = list as MutableList<MediaLibraryItem>
removeList(url)
parseSubDirectories()
true
} else super.refresh() } else super.refresh()
} }
override fun parseSubDirectories() { override fun parseSubDirectories() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment