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,
|
||||
GetItemsRequestHandler,
|
||||
viewModelScope,
|
||||
itemCount = item.data.childCount,
|
||||
)
|
||||
pager.init()
|
||||
episodes.value = pager
|
||||
|
|
|
|||
|
|
@ -111,7 +111,6 @@ class SeriesViewModel
|
|||
request,
|
||||
GetItemsRequestHandler,
|
||||
viewModelScope,
|
||||
itemCount = item.data.childCount,
|
||||
)
|
||||
pager.init()
|
||||
Timber.v("Loaded ${pager.size} seasons for series ${item.id}")
|
||||
|
|
|
|||
|
|
@ -82,11 +82,10 @@ class ApiRequestPager<T>(
|
|||
val requestHandler: RequestHandler<T>,
|
||||
private val scope: CoroutineScope,
|
||||
private val pageSize: Int = DEFAULT_PAGE_SIZE,
|
||||
itemCount: Int? = null,
|
||||
cacheSize: Long = 8,
|
||||
) : AbstractList<BaseItem?>() {
|
||||
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 cachedPages =
|
||||
CacheBuilder
|
||||
|
|
|
|||
|
|
@ -5,6 +5,9 @@ import androidx.lifecycle.MutableLiveData
|
|||
import com.github.damontecres.dolphin.DolphinApplication
|
||||
import kotlinx.coroutines.CancellationException
|
||||
import kotlinx.coroutines.CoroutineExceptionHandler
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import kotlinx.coroutines.withContext
|
||||
import timber.log.Timber
|
||||
import kotlin.coroutines.CoroutineContext
|
||||
|
||||
|
|
@ -25,11 +28,15 @@ class LoadingExceptionHandler(
|
|||
return
|
||||
}
|
||||
Timber.e(exception, "Exception in coroutine")
|
||||
loadingState.value =
|
||||
LoadingState.Error(
|
||||
message = errorMessage,
|
||||
exception = exception,
|
||||
)
|
||||
runBlocking {
|
||||
withContext(Dispatchers.Main) {
|
||||
loadingState.value =
|
||||
LoadingState.Error(
|
||||
message = errorMessage,
|
||||
exception = exception,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
if (autoToast) {
|
||||
Toast
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue