Fix webtoon reader leaving a gap after zooming in a resized window

The reader measured its height once, so zooming after a split screen or
window resize pinned it to the old size until the reader was reopened.

Closes #1721
This commit is contained in:
AntsyLich
2026-10-04 13:11:06 +06:00
parent f35bc341ae
commit d1c5c12bdd
@@ -7,6 +7,7 @@ import android.util.AttributeSet
import android.view.HapticFeedbackConstants
import android.view.MotionEvent
import android.view.ViewConfiguration
import android.view.ViewGroup.LayoutParams.MATCH_PARENT
import android.view.animation.DecelerateInterpolator
import androidx.core.animation.doOnEnd
import androidx.recyclerview.widget.LinearLayoutManager
@@ -30,7 +31,6 @@ class WebtoonRecyclerView @JvmOverloads constructor(
private var halfHeight = 0
var originalHeight = 0
private set
private var heightSet = false
private var firstVisibleItemPosition = 0
private var lastVisibleItemPosition = 0
private var currentScale = DEFAULT_RATE
@@ -58,9 +58,9 @@ class WebtoonRecyclerView @JvmOverloads constructor(
override fun onMeasure(widthSpec: Int, heightSpec: Int) {
halfWidth = MeasureSpec.getSize(widthSpec) / 2
halfHeight = MeasureSpec.getSize(heightSpec) / 2
if (!heightSet) {
// While zoomed out the height is set by zooming, not by the window
if (layoutParams?.height == MATCH_PARENT) {
originalHeight = MeasureSpec.getSize(heightSpec)
heightSet = true
}
super.onMeasure(widthSpec, heightSpec)
}
@@ -193,12 +193,13 @@ class WebtoonRecyclerView @JvmOverloads constructor(
setScaleRate(currentScale)
layoutParams.height = if (currentScale < 1) {
(originalHeight / currentScale).toInt()
if (currentScale < 1) {
layoutParams.height = (originalHeight / currentScale).toInt()
halfHeight = layoutParams.height / 2
} else {
originalHeight
layoutParams.height = MATCH_PARENT
halfHeight = originalHeight / 2
}
halfHeight = layoutParams.height / 2
if (currentScale != DEFAULT_RATE) {
x = getPositionX(x)
@@ -245,8 +246,8 @@ class WebtoonRecyclerView @JvmOverloads constructor(
if (!isZooming && doubleTapZoom) {
if (scaleX != DEFAULT_RATE) {
zoom(currentScale, DEFAULT_RATE, x, 0f, y, 0f)
layoutParams.height = originalHeight
halfHeight = layoutParams.height / 2
layoutParams.height = MATCH_PARENT
halfHeight = originalHeight / 2
requestLayout()
} else {
val toScale = 2f