mirror of
https://github.com/JustinZeus/Wholphin.git
synced 2026-07-08 15:50:16 +02:00
Fix counts
This commit is contained in:
parent
8bbcd50385
commit
0595c7174c
4 changed files with 13 additions and 9 deletions
|
|
@ -65,7 +65,6 @@ class SeasonViewModel
|
||||||
request,
|
request,
|
||||||
GetItemsRequestHandler,
|
GetItemsRequestHandler,
|
||||||
viewModelScope,
|
viewModelScope,
|
||||||
itemCount = item.data.childCount,
|
|
||||||
)
|
)
|
||||||
pager.init()
|
pager.init()
|
||||||
episodes.value = pager
|
episodes.value = pager
|
||||||
|
|
|
||||||
|
|
@ -111,7 +111,6 @@ class SeriesViewModel
|
||||||
request,
|
request,
|
||||||
GetItemsRequestHandler,
|
GetItemsRequestHandler,
|
||||||
viewModelScope,
|
viewModelScope,
|
||||||
itemCount = item.data.childCount,
|
|
||||||
)
|
)
|
||||||
pager.init()
|
pager.init()
|
||||||
Timber.v("Loaded ${pager.size} seasons for series ${item.id}")
|
Timber.v("Loaded ${pager.size} seasons for series ${item.id}")
|
||||||
|
|
|
||||||
|
|
@ -82,11 +82,10 @@ class ApiRequestPager<T>(
|
||||||
val requestHandler: RequestHandler<T>,
|
val requestHandler: RequestHandler<T>,
|
||||||
private val scope: CoroutineScope,
|
private val scope: CoroutineScope,
|
||||||
private val pageSize: Int = DEFAULT_PAGE_SIZE,
|
private val pageSize: Int = DEFAULT_PAGE_SIZE,
|
||||||
itemCount: Int? = null,
|
|
||||||
cacheSize: Long = 8,
|
cacheSize: Long = 8,
|
||||||
) : AbstractList<BaseItem?>() {
|
) : AbstractList<BaseItem?>() {
|
||||||
private var items by mutableStateOf(ItemList<BaseItem>(0, pageSize, mapOf()))
|
private var items by mutableStateOf(ItemList<BaseItem>(0, pageSize, mapOf()))
|
||||||
private var totalCount by mutableIntStateOf(itemCount ?: -1)
|
private var totalCount by mutableIntStateOf(-1)
|
||||||
private val mutex = Mutex()
|
private val mutex = Mutex()
|
||||||
private val cachedPages =
|
private val cachedPages =
|
||||||
CacheBuilder
|
CacheBuilder
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,9 @@ import androidx.lifecycle.MutableLiveData
|
||||||
import com.github.damontecres.dolphin.DolphinApplication
|
import com.github.damontecres.dolphin.DolphinApplication
|
||||||
import kotlinx.coroutines.CancellationException
|
import kotlinx.coroutines.CancellationException
|
||||||
import kotlinx.coroutines.CoroutineExceptionHandler
|
import kotlinx.coroutines.CoroutineExceptionHandler
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import kotlinx.coroutines.runBlocking
|
||||||
|
import kotlinx.coroutines.withContext
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import kotlin.coroutines.CoroutineContext
|
import kotlin.coroutines.CoroutineContext
|
||||||
|
|
||||||
|
|
@ -25,11 +28,15 @@ class LoadingExceptionHandler(
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
Timber.e(exception, "Exception in coroutine")
|
Timber.e(exception, "Exception in coroutine")
|
||||||
loadingState.value =
|
runBlocking {
|
||||||
LoadingState.Error(
|
withContext(Dispatchers.Main) {
|
||||||
message = errorMessage,
|
loadingState.value =
|
||||||
exception = exception,
|
LoadingState.Error(
|
||||||
)
|
message = errorMessage,
|
||||||
|
exception = exception,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (autoToast) {
|
if (autoToast) {
|
||||||
Toast
|
Toast
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue