refactor: Move stuff around

This commit is contained in:
Ahmad Ansori Palembani 2024-06-12 11:25:09 +07:00
parent 3b42210f10
commit 913f9b6b5c
Signed by: null2264
GPG key ID: BA64F8B60AF3EFB6

View file

@ -363,18 +363,20 @@ class PagerPageHolder(
val isAnimated = ImageUtil.isAnimatedAndSupported(actualSource) val isAnimated = ImageUtil.isAnimatedAndSupported(actualSource)
val bgColor = ReaderBackgroundColor.fromPreference(viewer.config.readerTheme) val bgColor = ReaderBackgroundColor.fromPreference(viewer.config.readerTheme)
val bgType = getBGType(viewer.config.readerTheme, context) val bgType = getBGType(viewer.config.readerTheme, context)
val background = if (!isAnimated && bgColor.isSmartColor) { val background = if (bgColor.isSmartColor) {
if (page.bg != null && page.bgType == bgType) page.bg if (!isAnimated) {
else { if (page.bg != null && page.bgType == bgType) page.bg
try { else {
setBG(actualSource.peek().inputStream()) try {
} catch (e: Exception) { setBG(actualSource.peek().inputStream())
Logger.e(e) { e.localizedMessage?.toString() ?: "" } } catch (e: Exception) {
ColorDrawable(Color.WHITE) Logger.e(e) { e.localizedMessage?.toString() ?: "" }
ColorDrawable(Color.WHITE)
}
} }
} else {
page.bg
} }
} else if (bgColor.isSmartColor && page.bg != null) {
page.bg
} else { } else {
null null
} }
@ -387,9 +389,9 @@ class PagerPageHolder(
withUIContext { withUIContext {
val (bg, bgType) = _bg val (bg, bgType) = _bg
if (bg != null) pageView?.background = bg if (bg != null) pageView?.background = bg
if (!isAnimated && page.bg == null && page.bgType != bgType) { if (!isAnimated) {
page.bg = pageView?.background if (page.bg == null) page.bg = pageView?.background
page.bgType = bgType if (page.bgType != bgType) page.bgType = bgType
} }
setImage(source, isAnimated, imageConfig) setImage(source, isAnimated, imageConfig)
} }