From 4868dd2d03214d0b1307cb42abd3e0a4cb5e85c6 Mon Sep 17 00:00:00 2001 From: arkon Date: Sat, 28 Oct 2023 17:18:42 -0400 Subject: [PATCH] Try to ensure that reader page error message is removed if image is loaded Maybe fixes #5687 --- .../presentation/reader/BrightnessOverlay.kt | 3 ++- .../tachiyomi/ui/reader/ReaderViewModel.kt | 3 ++- .../ui/reader/viewer/pager/PagerPageHolder.kt | 16 ++++++++++++---- .../reader/viewer/webtoon/WebtoonPageHolder.kt | 3 ++- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/eu/kanade/presentation/reader/BrightnessOverlay.kt b/app/src/main/java/eu/kanade/presentation/reader/BrightnessOverlay.kt index 144b8ea27..b945906a4 100644 --- a/app/src/main/java/eu/kanade/presentation/reader/BrightnessOverlay.kt +++ b/app/src/main/java/eu/kanade/presentation/reader/BrightnessOverlay.kt @@ -1,5 +1,6 @@ package eu.kanade.presentation.reader +import androidx.annotation.IntRange import androidx.compose.foundation.Canvas import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.runtime.Composable @@ -10,7 +11,7 @@ import kotlin.math.abs @Composable fun BrightnessOverlay( - value: Int, + @IntRange(from = -100, to = 100) value: Int, ) { if (value >= 0) return diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderViewModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderViewModel.kt index 201c2eaa3..1c9e4578d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderViewModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderViewModel.kt @@ -2,6 +2,7 @@ package eu.kanade.tachiyomi.ui.reader import android.app.Application import android.net.Uri +import androidx.annotation.IntRange import androidx.compose.runtime.Immutable import androidx.lifecycle.SavedStateHandle import androidx.lifecycle.ViewModel @@ -900,7 +901,7 @@ class ReaderViewModel @JvmOverloads constructor( val viewer: Viewer? = null, val dialog: Dialog? = null, val menuVisible: Boolean = false, - val brightnessOverlayValue: Int = 0, + @IntRange(from = -100, to = 100) val brightnessOverlayValue: Int = 0, ) { val currentChapter: ReaderChapter? get() = viewerChapters?.currChapter diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerPageHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerPageHolder.kt index e1fd80ff5..51e9652aa 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerPageHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerPageHolder.kt @@ -109,7 +109,7 @@ class PagerPageHolder( */ private fun setQueued() { progressIndicator.show() - errorLayout?.root?.isVisible = false + removeErrorLayout() } /** @@ -117,7 +117,7 @@ class PagerPageHolder( */ private fun setLoading() { progressIndicator.show() - errorLayout?.root?.isVisible = false + removeErrorLayout() } /** @@ -125,7 +125,7 @@ class PagerPageHolder( */ private fun setDownloading() { progressIndicator.show() - errorLayout?.root?.isVisible = false + removeErrorLayout() } /** @@ -133,7 +133,6 @@ class PagerPageHolder( */ private suspend fun setImage() { progressIndicator.setProgress(0) - errorLayout?.root?.isVisible = false val streamFn = page.stream ?: return @@ -170,6 +169,7 @@ class PagerPageHolder( pageBackground = background } } + removeErrorLayout() } } @@ -280,4 +280,12 @@ class PagerPageHolder( errorLayout?.root?.isVisible = true return errorLayout!! } + + /** + * Removes the decode error layout from the holder, if found. + */ + private fun removeErrorLayout() { + errorLayout?.root?.isVisible = false + errorLayout = null + } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonPageHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonPageHolder.kt index 7fa2058d6..aeb25d905 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonPageHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonPageHolder.kt @@ -181,7 +181,6 @@ class WebtoonPageHolder( */ private suspend fun setImage() { progressIndicator.setProgress(0) - removeErrorLayout() val streamFn = page?.stream ?: return @@ -202,6 +201,7 @@ class WebtoonPageHolder( cropBorders = viewer.config.imageCropBorders, ), ) + removeErrorLayout() } // Suspend the coroutine to close the input stream only when the WebtoonPageHolder is recycled suspendCancellableCoroutine { continuation -> @@ -234,6 +234,7 @@ class WebtoonPageHolder( */ private fun onImageDecoded() { progressContainer.isVisible = false + removeErrorLayout() } /**