fix(reader): Prevent potential NPE

This commit is contained in:
Ahmad Ansori Palembani 2024-12-08 06:47:02 +07:00
parent 8bc22fec28
commit a4ab7f11e2
Signed by: null2264
GPG key ID: BA64F8B60AF3EFB6

View file

@ -301,8 +301,7 @@ class PagerPageHolder(
private fun SubsamplingScaleImageView.landscapeZoom(forward: Boolean?) {
forward ?: return
if (viewer.config.landscapeZoom && viewer.config.imageScaleType == SubsamplingScaleImageView.SCALE_TYPE_CENTER_INSIDE && sWidth > sHeight && scale == minScale) {
handler.postDelayed(
{
handler.postDelayed(500) {
val point = when (viewer.config.imageZoomType) {
ZoomType.Left -> if (forward) PointF(0F, 0F) else PointF(sWidth.toFloat(), 0F)
ZoomType.Right -> if (forward) PointF(sWidth.toFloat(), 0F) else PointF(0F, 0F)
@ -321,14 +320,12 @@ class PagerPageHolder(
rootInsets?.bottomCutoutInset()?.toFloat() ?: 0f
}
val targetScale = (height.toFloat() - topInsets - bottomInsets) / sHeight.toFloat()
animateScaleAndCenter(min(targetScale, minScale * 2), point)!!
(animateScaleAndCenter(min(targetScale, minScale * 2), point) ?: return@postDelayed)
.withDuration(500)
.withEasing(SubsamplingScaleImageView.EASE_IN_OUT_QUAD)
.withInterruptible(true)
.start()
},
500,
)
}
}
}