mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
fix(reader): Prevent potential NPE
This commit is contained in:
parent
8bc22fec28
commit
a4ab7f11e2
1 changed files with 24 additions and 27 deletions
|
@ -301,34 +301,31 @@ class PagerPageHolder(
|
||||||
private fun SubsamplingScaleImageView.landscapeZoom(forward: Boolean?) {
|
private fun SubsamplingScaleImageView.landscapeZoom(forward: Boolean?) {
|
||||||
forward ?: return
|
forward ?: return
|
||||||
if (viewer.config.landscapeZoom && viewer.config.imageScaleType == SubsamplingScaleImageView.SCALE_TYPE_CENTER_INSIDE && sWidth > sHeight && scale == minScale) {
|
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) {
|
||||||
val point = when (viewer.config.imageZoomType) {
|
ZoomType.Left -> if (forward) PointF(0F, 0F) else PointF(sWidth.toFloat(), 0F)
|
||||||
ZoomType.Left -> if (forward) PointF(0F, 0F) else PointF(sWidth.toFloat(), 0F)
|
ZoomType.Right -> if (forward) PointF(sWidth.toFloat(), 0F) else PointF(0F, 0F)
|
||||||
ZoomType.Right -> if (forward) PointF(sWidth.toFloat(), 0F) else PointF(0F, 0F)
|
ZoomType.Center -> center.also { it?.y = 0F }
|
||||||
ZoomType.Center -> center.also { it?.y = 0F }
|
}
|
||||||
}
|
|
||||||
|
|
||||||
val rootInsets = viewer.activity.window.decorView.rootWindowInsets
|
val rootInsets = viewer.activity.window.decorView.rootWindowInsets
|
||||||
val topInsets = if (viewer.activity.isSplitScreen) {
|
val topInsets = if (viewer.activity.isSplitScreen) {
|
||||||
0f
|
0f
|
||||||
} else {
|
} else {
|
||||||
rootInsets?.topCutoutInset()?.toFloat() ?: 0f
|
rootInsets?.topCutoutInset()?.toFloat() ?: 0f
|
||||||
}
|
}
|
||||||
val bottomInsets = if (viewer.activity.isSplitScreen) {
|
val bottomInsets = if (viewer.activity.isSplitScreen) {
|
||||||
0f
|
0f
|
||||||
} else {
|
} else {
|
||||||
rootInsets?.bottomCutoutInset()?.toFloat() ?: 0f
|
rootInsets?.bottomCutoutInset()?.toFloat() ?: 0f
|
||||||
}
|
}
|
||||||
val targetScale = (height.toFloat() - topInsets - bottomInsets) / sHeight.toFloat()
|
val targetScale = (height.toFloat() - topInsets - bottomInsets) / sHeight.toFloat()
|
||||||
animateScaleAndCenter(min(targetScale, minScale * 2), point)!!
|
(animateScaleAndCenter(min(targetScale, minScale * 2), point) ?: return@postDelayed)
|
||||||
.withDuration(500)
|
.withDuration(500)
|
||||||
.withEasing(SubsamplingScaleImageView.EASE_IN_OUT_QUAD)
|
.withEasing(SubsamplingScaleImageView.EASE_IN_OUT_QUAD)
|
||||||
.withInterruptible(true)
|
.withInterruptible(true)
|
||||||
.start()
|
.start()
|
||||||
},
|
}
|
||||||
500,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue