Commit a8d248b1 authored by Geoffrey Métais's avatar Geoffrey Métais

Finer dispatch for ViewModels init

parent 6b5de438
......@@ -54,7 +54,7 @@ abstract class BaseModel<T : MediaLibraryItem> : ViewModel(), RefreshModel {
private val filter by lazy(LazyThreadSafetyMode.NONE) { FilterDelegate(dataset) }
val dataset by lazy {
launch(UI) { fetch() }
fetch()
LiveDataset<T>()
}
......
......@@ -27,6 +27,7 @@ import org.videolan.medialibrary.interfaces.MediaAddedCb
import org.videolan.medialibrary.interfaces.MediaUpdatedCb
import org.videolan.medialibrary.media.MediaLibraryItem
import org.videolan.vlc.util.EmptyMLCallbacks
import org.videolan.vlc.util.uiStart
abstract class MedialibraryModel<T : MediaLibraryItem> : BaseModel<T>(), Medialibrary.OnMedialibraryReadyListener, MediaUpdatedCb by EmptyMLCallbacks, MediaAddedCb by EmptyMLCallbacks {
......@@ -39,11 +40,11 @@ abstract class MedialibraryModel<T : MediaLibraryItem> : BaseModel<T>(), Mediali
}
override fun onMedialibraryReady() {
launch(UI) { refresh() }
launch(UI, uiStart()) { refresh() }
}
override fun onMedialibraryIdle() {
launch(UI) { refresh() }
launch(UI, uiStart()) { refresh() }
}
override fun onCleared() {
......
......@@ -54,12 +54,16 @@ abstract class BrowserProvider(val url: String?, private val showHiddenFiles: Bo
override fun fetch() {
val prefetchList by lazy(LazyThreadSafetyMode.NONE) { prefetchLists[url] }
if (url === null) {
browseRoot()
parseSubDirectories()
launch(UI) {
browseRoot()
parseSubDirectories()
}
} else if (prefetchList !== null && !prefetchList.isEmpty()) {
dataset.value = prefetchList
prefetchLists.remove(url)
parseSubDirectories()
launch(UI) {
dataset.value = prefetchList
prefetchLists.remove(url)
parseSubDirectories()
}
} else browse(url, browserListener)
}
......
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