Try to ensure that reader page error message is removed if image is loaded

Maybe fixes #5687

(cherry picked from commit 4868dd2d03214d0b1307cb42abd3e0a4cb5e85c6)

# Conflicts:
#	app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderViewModel.kt
#	app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerPageHolder.kt
This commit is contained in:
arkon 2023-10-28 17:18:42 -04:00 committed by Jobobby04
parent ee212460b3
commit 5f7d56b6d2
4 changed files with 18 additions and 7 deletions

View File

@ -1,5 +1,6 @@
package eu.kanade.presentation.reader package eu.kanade.presentation.reader
import androidx.annotation.IntRange
import androidx.compose.foundation.Canvas import androidx.compose.foundation.Canvas
import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
@ -10,7 +11,7 @@ import kotlin.math.abs
@Composable @Composable
fun BrightnessOverlay( fun BrightnessOverlay(
value: Int, @IntRange(from = -100, to = 100) value: Int,
) { ) {
if (value >= 0) return if (value >= 0) return

View File

@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.ui.reader
import android.app.Application import android.app.Application
import android.net.Uri import android.net.Uri
import androidx.annotation.ColorInt import androidx.annotation.ColorInt
import androidx.annotation.IntRange
import androidx.compose.runtime.Immutable import androidx.compose.runtime.Immutable
import androidx.lifecycle.SavedStateHandle import androidx.lifecycle.SavedStateHandle
import androidx.lifecycle.ViewModel import androidx.lifecycle.ViewModel
@ -1250,7 +1251,7 @@ class ReaderViewModel @JvmOverloads constructor(
val viewer: Viewer? = null, val viewer: Viewer? = null,
val dialog: Dialog? = null, val dialog: Dialog? = null,
val menuVisible: Boolean = false, val menuVisible: Boolean = false,
val brightnessOverlayValue: Int = 0, @IntRange(from = -100, to = 100) val brightnessOverlayValue: Int = 0,
// SY --> // SY -->
val currentPageText: String = "", val currentPageText: String = "",

View File

@ -126,7 +126,7 @@ class PagerPageHolder(
*/ */
private fun setQueued() { private fun setQueued() {
progressIndicator.show() progressIndicator.show()
errorLayout?.root?.isVisible = false removeErrorLayout()
} }
/** /**
@ -134,7 +134,7 @@ class PagerPageHolder(
*/ */
private fun setLoading() { private fun setLoading() {
progressIndicator.show() progressIndicator.show()
errorLayout?.root?.isVisible = false removeErrorLayout()
} }
/** /**
@ -142,7 +142,7 @@ class PagerPageHolder(
*/ */
private fun setDownloading() { private fun setDownloading() {
progressIndicator.show() progressIndicator.show()
errorLayout?.root?.isVisible = false removeErrorLayout()
} }
/** /**
@ -154,7 +154,6 @@ class PagerPageHolder(
} else { } else {
progressIndicator.setProgress(95) progressIndicator.setProgress(95)
} }
errorLayout?.root?.isVisible = false
val streamFn = page.stream ?: return val streamFn = page.stream ?: return
val streamFn2 = extraPage?.stream val streamFn2 = extraPage?.stream
@ -207,6 +206,7 @@ class PagerPageHolder(
pageBackground = background pageBackground = background
} }
} }
removeErrorLayout()
} }
} }
@ -456,4 +456,12 @@ class PagerPageHolder(
errorLayout?.root?.isVisible = true errorLayout?.root?.isVisible = true
return errorLayout!! return errorLayout!!
} }
/**
* Removes the decode error layout from the holder, if found.
*/
private fun removeErrorLayout() {
errorLayout?.root?.isVisible = false
errorLayout = null
}
} }

View File

@ -181,7 +181,6 @@ class WebtoonPageHolder(
*/ */
private suspend fun setImage() { private suspend fun setImage() {
progressIndicator.setProgress(0) progressIndicator.setProgress(0)
removeErrorLayout()
val streamFn = page?.stream ?: return val streamFn = page?.stream ?: return
@ -202,6 +201,7 @@ class WebtoonPageHolder(
cropBorders = (viewer.config.imageCropBorders && viewer.isContinuous) || (viewer.config.continuousCropBorders && !viewer.isContinuous), cropBorders = (viewer.config.imageCropBorders && viewer.isContinuous) || (viewer.config.continuousCropBorders && !viewer.isContinuous),
), ),
) )
removeErrorLayout()
} }
// Suspend the coroutine to close the input stream only when the WebtoonPageHolder is recycled // Suspend the coroutine to close the input stream only when the WebtoonPageHolder is recycled
suspendCancellableCoroutine<Nothing> { continuation -> suspendCancellableCoroutine<Nothing> { continuation ->
@ -240,6 +240,7 @@ class WebtoonPageHolder(
*/ */
private fun onImageDecoded() { private fun onImageDecoded() {
progressContainer.isVisible = false progressContainer.isVisible = false
removeErrorLayout()
} }
/** /**