Avoid showing WebView button in reader errors if page isn't actually from web
This commit is contained in:
parent
f8ef0f143b
commit
bbd8098a61
@ -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)) {
|
||||
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!!
|
||||
}
|
||||
|
@ -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)) {
|
||||
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!!
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user