Commit 8096bffa authored by Geoffrey Métais's avatar Geoffrey Métais
Browse files

Fix loading state toggling

parent cd93c94c
Pipeline #16954 failed with stage
in 2 minutes and 2 seconds
......@@ -44,7 +44,7 @@ abstract class MedialibraryProvider<T : MediaLibraryItem>(val context: Context,
private lateinit var dataSource : DataSource<Int, T>
val loading = MutableLiveData<Boolean>().apply { value = true }
private var refreshDeferred : CompletableDeferred<Unit>? = null
var isRefreshing = medialibrary.isWorking
var isRefreshing = true
private set(value) {
refreshDeferred = if (value) CompletableDeferred()
else {
......@@ -95,7 +95,7 @@ abstract class MedialibraryProvider<T : MediaLibraryItem>(val context: Context,
}
fun refresh(): Boolean {
if (isRefreshing || !medialibrary.isStarted || !this::dataSource.isInitialized) return false
if (medialibrary.isWorking || !medialibrary.isStarted || !this::dataSource.isInitialized) return false
privateHeaders.clear()
if (!dataSource.isInvalid) {
isRefreshing = true
......@@ -128,7 +128,7 @@ abstract class MedialibraryProvider<T : MediaLibraryItem>(val context: Context,
try {
callback.onResult(page.toList(), params.requestedStartPosition, count)
} catch (e: IllegalArgumentException) {}
isRefreshing = false
isRefreshing = !medialibrary.isStarted
}
override fun loadRange(params: LoadRangeParams, callback: LoadRangeCallback<T>) {
......
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