Albirew/tachiyomi
Archivé
1
0
Bifurcation 0

Avoid showing WebView button in reader errors if page isn't actually from web

Cette révision appartient à :
arkon 2024-01-06 16:55:50 -05:00
Parent f8ef0f143b
révision bbd8098a61
2 fichiers modifiés avec 22 ajouts et 23 suppressions

Voir le fichier

@ -235,7 +235,7 @@ class PagerPageHolder(
*/
private fun setError() {
progressIndicator.hide()
showErrorLayout(withOpenInWebView = false)
showErrorLayout()
}
override fun onImageLoaded() {
@ -248,8 +248,7 @@ class PagerPageHolder(
*/
override fun onImageLoadError() {
super.onImageLoadError()
progressIndicator.hide()
showErrorLayout(withOpenInWebView = true)
setError()
}
/**
@ -260,23 +259,27 @@ class PagerPageHolder(
viewer.activity.hideMenu()
}
private fun showErrorLayout(withOpenInWebView: Boolean): ReaderErrorBinding {
private fun showErrorLayout(): ReaderErrorBinding {
if (errorLayout == null) {
errorLayout = ReaderErrorBinding.inflate(LayoutInflater.from(context), this, true)
errorLayout?.actionRetry?.viewer = viewer
errorLayout?.actionRetry?.setOnClickListener {
page.chapter.pageLoader?.retryPage(page)
}
val imageUrl = page.imageUrl
if (imageUrl.orEmpty().startsWith("http", true)) {
}
val imageUrl = page.imageUrl
errorLayout?.actionOpenInWebView?.isVisible = imageUrl != null
if (imageUrl != null) {
if (imageUrl.startsWith("http", true)) {
errorLayout?.actionOpenInWebView?.viewer = viewer
errorLayout?.actionOpenInWebView?.setOnClickListener {
val intent = WebViewActivity.newIntent(context, imageUrl!!)
val intent = WebViewActivity.newIntent(context, imageUrl)
context.startActivity(intent)
}
}
}
errorLayout?.actionOpenInWebView?.isVisible = withOpenInWebView
errorLayout?.root?.isVisible = true
return errorLayout!!
}

Voir le fichier

@ -80,7 +80,7 @@ class WebtoonPageHolder(
refreshLayoutParams()
frame.onImageLoaded = { onImageDecoded() }
frame.onImageLoadError = { onImageDecodeError() }
frame.onImageLoadError = { setError() }
frame.onScaleChanged = { viewer.activity.hideMenu() }
}
@ -240,7 +240,7 @@ class WebtoonPageHolder(
*/
private fun setError() {
progressContainer.isVisible = false
initErrorLayout(withOpenInWebView = false)
initErrorLayout()
}
/**
@ -251,14 +251,6 @@ class WebtoonPageHolder(
removeErrorLayout()
}
/**
* Called when the image fails to decode.
*/
private fun onImageDecodeError() {
progressContainer.isVisible = false
initErrorLayout(withOpenInWebView = true)
}
/**
* Creates a new progress bar.
*/
@ -278,22 +270,26 @@ class WebtoonPageHolder(
/**
* Initializes a button to retry pages.
*/
private fun initErrorLayout(withOpenInWebView: Boolean): ReaderErrorBinding {
private fun initErrorLayout(): ReaderErrorBinding {
if (errorLayout == null) {
errorLayout = ReaderErrorBinding.inflate(LayoutInflater.from(context), frame, true)
errorLayout?.root?.layoutParams = FrameLayout.LayoutParams(MATCH_PARENT, (parentHeight * 0.8).toInt())
errorLayout?.actionRetry?.setOnClickListener {
page?.let { it.chapter.pageLoader?.retryPage(it) }
}
val imageUrl = page?.imageUrl
if (imageUrl.orEmpty().startsWith("http", true)) {
}
val imageUrl = page?.imageUrl
errorLayout?.actionOpenInWebView?.isVisible = imageUrl != null
if (imageUrl != null) {
if (imageUrl.startsWith("http", true)) {
errorLayout?.actionOpenInWebView?.setOnClickListener {
val intent = WebViewActivity.newIntent(context, imageUrl!!)
val intent = WebViewActivity.newIntent(context, imageUrl)
context.startActivity(intent)
}
}
}
errorLayout?.actionOpenInWebView?.isVisible = withOpenInWebView
return errorLayout!!
}