Fix a possible crash with auto-zoom

(cherry picked from commit 26cfb4811fef4059fb7e8e03361c141932fec6b5)
This commit is contained in:
Jobobby04 2024-11-07 22:21:39 -05:00 committed by Cuong-Tran
parent 2524488162
commit 54aecf3ff6
No known key found for this signature in database
GPG key ID: 733AA7624B9315C2

View file

@ -122,21 +122,22 @@ open class ReaderPageImageView @JvmOverloads constructor(
}
private fun SubsamplingScaleImageView.landscapeZoom(forward: Boolean) {
val config = config
if (config != null &&
config!!.landscapeZoom &&
config!!.minimumScaleType == SCALE_TYPE_CENTER_INSIDE &&
config.landscapeZoom &&
config.minimumScaleType == SCALE_TYPE_CENTER_INSIDE &&
sWidth > sHeight &&
scale == minScale
) {
handler?.postDelayed(500) {
val point = when (config!!.zoomStartPosition) {
val point = when (config.zoomStartPosition) {
ZoomStartPosition.LEFT -> if (forward) PointF(0F, 0F) else PointF(sWidth.toFloat(), 0F)
ZoomStartPosition.RIGHT -> if (forward) PointF(sWidth.toFloat(), 0F) else PointF(0F, 0F)
ZoomStartPosition.CENTER -> center
}
val targetScale = height.toFloat() / sHeight.toFloat()
animateScaleAndCenter(targetScale, point)!!
(animateScaleAndCenter(targetScale, point) ?: return@postDelayed)
.withDuration(500)
.withEasing(EASE_IN_OUT_QUAD)
.withInterruptible(true)