Fix a possible crash with auto-zoom
This commit is contained in:
parent
e5a6d1b456
commit
26cfb4811f
@ -122,21 +122,22 @@ open class ReaderPageImageView @JvmOverloads constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun SubsamplingScaleImageView.landscapeZoom(forward: Boolean) {
|
private fun SubsamplingScaleImageView.landscapeZoom(forward: Boolean) {
|
||||||
|
val config = config
|
||||||
if (config != null &&
|
if (config != null &&
|
||||||
config!!.landscapeZoom &&
|
config.landscapeZoom &&
|
||||||
config!!.minimumScaleType == SCALE_TYPE_CENTER_INSIDE &&
|
config.minimumScaleType == SCALE_TYPE_CENTER_INSIDE &&
|
||||||
sWidth > sHeight &&
|
sWidth > sHeight &&
|
||||||
scale == minScale
|
scale == minScale
|
||||||
) {
|
) {
|
||||||
handler?.postDelayed(500) {
|
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.LEFT -> if (forward) PointF(0F, 0F) else PointF(sWidth.toFloat(), 0F)
|
||||||
ZoomStartPosition.RIGHT -> if (forward) PointF(sWidth.toFloat(), 0F) else PointF(0F, 0F)
|
ZoomStartPosition.RIGHT -> if (forward) PointF(sWidth.toFloat(), 0F) else PointF(0F, 0F)
|
||||||
ZoomStartPosition.CENTER -> center
|
ZoomStartPosition.CENTER -> center
|
||||||
}
|
}
|
||||||
|
|
||||||
val targetScale = height.toFloat() / sHeight.toFloat()
|
val targetScale = height.toFloat() / sHeight.toFloat()
|
||||||
animateScaleAndCenter(targetScale, point)!!
|
(animateScaleAndCenter(targetScale, point) ?: return@postDelayed)
|
||||||
.withDuration(500)
|
.withDuration(500)
|
||||||
.withEasing(EASE_IN_OUT_QUAD)
|
.withEasing(EASE_IN_OUT_QUAD)
|
||||||
.withInterruptible(true)
|
.withInterruptible(true)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user