From 0f48ad07a3ad25963a6f2e8ba092bc95d8f83e9f Mon Sep 17 00:00:00 2001 From: Koitharu Date: Sun, 4 Apr 2021 11:18:12 +0300 Subject: [PATCH] Support no-fullheight pages in webtoon mode --- .idea/misc.xml | 1 + .../kotatsu/reader/ui/pager/wetoon/WebtoonImageView.kt | 9 +++++++++ app/src/main/res/layout/item_page_webtoon.xml | 4 ++-- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index 8fcbed2dc..caf674bd0 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -23,6 +23,7 @@ + diff --git a/app/src/main/java/org/koitharu/kotatsu/reader/ui/pager/wetoon/WebtoonImageView.kt b/app/src/main/java/org/koitharu/kotatsu/reader/ui/pager/wetoon/WebtoonImageView.kt index 3e9e7a244..88845b512 100644 --- a/app/src/main/java/org/koitharu/kotatsu/reader/ui/pager/wetoon/WebtoonImageView.kt +++ b/app/src/main/java/org/koitharu/kotatsu/reader/ui/pager/wetoon/WebtoonImageView.kt @@ -10,6 +10,7 @@ class WebtoonImageView @JvmOverloads constructor(context: Context, attr: Attribu SubsamplingScaleImageView(context, attr) { private val ct = PointF() + private val displayHeight = resources.displayMetrics.heightPixels private var scrollPos = 0 private var scrollRange = SCROLL_UNKNOWN @@ -46,6 +47,14 @@ class WebtoonImageView @JvmOverloads constructor(context: Context, attr: Attribu super.recycle() } + override fun getSuggestedMinimumHeight(): Int { + var desiredHeight = super.getSuggestedMinimumHeight() + if (sHeight == 0 && desiredHeight < displayHeight) { + desiredHeight = displayHeight + } + return desiredHeight + } + private fun scrollToInternal(pos: Int) { scrollPos = pos ct.set(sWidth / 2f, (height / 2f + pos.toFloat()) / minScale) diff --git a/app/src/main/res/layout/item_page_webtoon.xml b/app/src/main/res/layout/item_page_webtoon.xml index 7ee3bac7a..f032e1819 100644 --- a/app/src/main/res/layout/item_page_webtoon.xml +++ b/app/src/main/res/layout/item_page_webtoon.xml @@ -4,12 +4,12 @@ xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" - android:layout_height="match_parent"> + android:layout_height="wrap_content">