From 8f0f0d5600ddab67e0c5a5d451421734612f24c3 Mon Sep 17 00:00:00 2001 From: michaelbel Date: Sun, 3 Mar 2024 22:28:05 +0300 Subject: [PATCH] Update project --- .../movies/ui/ktx/LazyPagingItemsKtx.kt | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/core/ui/src/main/kotlin/org/michaelbel/movies/ui/ktx/LazyPagingItemsKtx.kt b/core/ui/src/main/kotlin/org/michaelbel/movies/ui/ktx/LazyPagingItemsKtx.kt index 9e4ec2050..150d20ddc 100644 --- a/core/ui/src/main/kotlin/org/michaelbel/movies/ui/ktx/LazyPagingItemsKtx.kt +++ b/core/ui/src/main/kotlin/org/michaelbel/movies/ui/ktx/LazyPagingItemsKtx.kt @@ -17,13 +17,25 @@ val LazyPagingItems.isFailure: Boolean get() = loadState.refresh is LoadState.Error && isEmpty val LazyPagingItems.isPagingLoading: Boolean - get() = loadState.append is LoadState.Loading && isNotEmpty + get() = isNotEmpty && (isAppendLoading || isAppendRefresh) val LazyPagingItems.isPagingFailure: Boolean - get() = loadState.append is LoadState.Error && appendThrowable !is PageEmptyException && isNotEmpty + get() = isNotEmpty && (isAppendError && appendThrowable !is PageEmptyException || isRefreshError && refreshThrowable !is PageEmptyException) + +val LazyPagingItems.isRefreshError: Boolean + get() = loadState.refresh is LoadState.Error + +val LazyPagingItems.isAppendError: Boolean + get() = loadState.append is LoadState.Error val LazyPagingItems.refreshThrowable: Throwable get() = (loadState.refresh as LoadState.Error).error val LazyPagingItems.appendThrowable: Throwable - get() = (loadState.append as LoadState.Error).error \ No newline at end of file + get() = (loadState.append as LoadState.Error).error + +val LazyPagingItems.isAppendLoading: Boolean + get() = loadState.append is LoadState.Loading + +val LazyPagingItems.isAppendRefresh: Boolean + get() = loadState.refresh is LoadState.Loading \ No newline at end of file