mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-06 04:05:09 +01:00
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() {
|
private fun setError() {
|
||||||
progressIndicator.hide()
|
progressIndicator.hide()
|
||||||
showErrorLayout(withOpenInWebView = false)
|
showErrorLayout()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onImageLoaded() {
|
override fun onImageLoaded() {
|
||||||
@ -248,8 +248,7 @@ class PagerPageHolder(
|
|||||||
*/
|
*/
|
||||||
override fun onImageLoadError() {
|
override fun onImageLoadError() {
|
||||||
super.onImageLoadError()
|
super.onImageLoadError()
|
||||||
progressIndicator.hide()
|
setError()
|
||||||
showErrorLayout(withOpenInWebView = true)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -260,23 +259,27 @@ class PagerPageHolder(
|
|||||||
viewer.activity.hideMenu()
|
viewer.activity.hideMenu()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun showErrorLayout(withOpenInWebView: Boolean): ReaderErrorBinding {
|
private fun showErrorLayout(): ReaderErrorBinding {
|
||||||
if (errorLayout == null) {
|
if (errorLayout == null) {
|
||||||
errorLayout = ReaderErrorBinding.inflate(LayoutInflater.from(context), this, true)
|
errorLayout = ReaderErrorBinding.inflate(LayoutInflater.from(context), this, true)
|
||||||
errorLayout?.actionRetry?.viewer = viewer
|
errorLayout?.actionRetry?.viewer = viewer
|
||||||
errorLayout?.actionRetry?.setOnClickListener {
|
errorLayout?.actionRetry?.setOnClickListener {
|
||||||
page.chapter.pageLoader?.retryPage(page)
|
page.chapter.pageLoader?.retryPage(page)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
val imageUrl = page.imageUrl
|
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?.viewer = viewer
|
||||||
errorLayout?.actionOpenInWebView?.setOnClickListener {
|
errorLayout?.actionOpenInWebView?.setOnClickListener {
|
||||||
val intent = WebViewActivity.newIntent(context, imageUrl!!)
|
val intent = WebViewActivity.newIntent(context, imageUrl)
|
||||||
context.startActivity(intent)
|
context.startActivity(intent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
errorLayout?.actionOpenInWebView?.isVisible = withOpenInWebView
|
|
||||||
errorLayout?.root?.isVisible = true
|
errorLayout?.root?.isVisible = true
|
||||||
return errorLayout!!
|
return errorLayout!!
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,7 @@ class WebtoonPageHolder(
|
|||||||
refreshLayoutParams()
|
refreshLayoutParams()
|
||||||
|
|
||||||
frame.onImageLoaded = { onImageDecoded() }
|
frame.onImageLoaded = { onImageDecoded() }
|
||||||
frame.onImageLoadError = { onImageDecodeError() }
|
frame.onImageLoadError = { setError() }
|
||||||
frame.onScaleChanged = { viewer.activity.hideMenu() }
|
frame.onScaleChanged = { viewer.activity.hideMenu() }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -240,7 +240,7 @@ class WebtoonPageHolder(
|
|||||||
*/
|
*/
|
||||||
private fun setError() {
|
private fun setError() {
|
||||||
progressContainer.isVisible = false
|
progressContainer.isVisible = false
|
||||||
initErrorLayout(withOpenInWebView = false)
|
initErrorLayout()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -251,14 +251,6 @@ class WebtoonPageHolder(
|
|||||||
removeErrorLayout()
|
removeErrorLayout()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when the image fails to decode.
|
|
||||||
*/
|
|
||||||
private fun onImageDecodeError() {
|
|
||||||
progressContainer.isVisible = false
|
|
||||||
initErrorLayout(withOpenInWebView = true)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new progress bar.
|
* Creates a new progress bar.
|
||||||
*/
|
*/
|
||||||
@ -278,22 +270,26 @@ class WebtoonPageHolder(
|
|||||||
/**
|
/**
|
||||||
* Initializes a button to retry pages.
|
* Initializes a button to retry pages.
|
||||||
*/
|
*/
|
||||||
private fun initErrorLayout(withOpenInWebView: Boolean): ReaderErrorBinding {
|
private fun initErrorLayout(): ReaderErrorBinding {
|
||||||
if (errorLayout == null) {
|
if (errorLayout == null) {
|
||||||
errorLayout = ReaderErrorBinding.inflate(LayoutInflater.from(context), frame, true)
|
errorLayout = ReaderErrorBinding.inflate(LayoutInflater.from(context), frame, true)
|
||||||
errorLayout?.root?.layoutParams = FrameLayout.LayoutParams(MATCH_PARENT, (parentHeight * 0.8).toInt())
|
errorLayout?.root?.layoutParams = FrameLayout.LayoutParams(MATCH_PARENT, (parentHeight * 0.8).toInt())
|
||||||
errorLayout?.actionRetry?.setOnClickListener {
|
errorLayout?.actionRetry?.setOnClickListener {
|
||||||
page?.let { it.chapter.pageLoader?.retryPage(it) }
|
page?.let { it.chapter.pageLoader?.retryPage(it) }
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
val imageUrl = page?.imageUrl
|
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 {
|
errorLayout?.actionOpenInWebView?.setOnClickListener {
|
||||||
val intent = WebViewActivity.newIntent(context, imageUrl!!)
|
val intent = WebViewActivity.newIntent(context, imageUrl)
|
||||||
context.startActivity(intent)
|
context.startActivity(intent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
errorLayout?.actionOpenInWebView?.isVisible = withOpenInWebView
|
|
||||||
return errorLayout!!
|
return errorLayout!!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user