Fix wonky webtoon layout when image is loaded at the top of the screen (#5660)

This commit is contained in:
Ivan Iskandar 2021-08-06 04:51:03 +07:00 committed by GitHub
parent 5aea21a194
commit 40aa3b7e18
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -266,7 +266,6 @@ class WebtoonPageHolder(
*/ */
private fun setImage() { private fun setImage() {
progressIndicator.setCompleteProgressAndHide() progressIndicator.setCompleteProgressAndHide()
progressContainer.isVisible = false
retryContainer?.isVisible = false retryContainer?.isVisible = false
removeDecodeErrorLayout() removeDecodeErrorLayout()
@ -324,6 +323,13 @@ class WebtoonPageHolder(
initRetryLayout().isVisible = true initRetryLayout().isVisible = true
} }
/**
* Called when the image is decoded and going to be displayed.
*/
private fun onImageDecoded() {
progressContainer.isVisible = false
}
/** /**
* Called when the image fails to decode. * Called when the image fails to decode.
*/ */
@ -374,6 +380,10 @@ class WebtoonPageHolder(
setCropBorders(cropBorders) setCropBorders(cropBorders)
setOnImageEventListener( setOnImageEventListener(
object : SubsamplingScaleImageView.DefaultOnImageEventListener() { object : SubsamplingScaleImageView.DefaultOnImageEventListener() {
override fun onReady() {
onImageDecoded()
}
override fun onImageLoadError(e: Exception) { override fun onImageLoadError(e: Exception) {
onImageDecodeError() onImageDecodeError()
} }
@ -505,6 +515,7 @@ class WebtoonPageHolder(
result.start() result.start()
} }
setImageDrawable(result) setImageDrawable(result)
onImageDecoded()
}, },
onError = { onError = {
onImageDecodeError() onImageDecodeError()