Cleanup logic of onStripSplit in WebtoonPageHolder (#7955)

* Cleanup logic of `onStripSplit` in WebtoonPageHolder

* Update app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonPageHolder.kt

Co-authored-by: arkon <arkon@users.noreply.github.com>
This commit is contained in:
AntsyLich
2022-09-08 03:11:44 +06:00
committed by GitHub
parent 0c7b1bda7f
commit 6b91f65457
2 changed files with 17 additions and 17 deletions

View File

@@ -261,7 +261,7 @@ object ImageUtil {
val options = extractImageOptions(imageStream)
val imageHeightIsBiggerThanWidth = options.outHeight > options.outWidth
val imageHeightBiggerThanScreenHeight = options.outHeight > getDisplayMaxHeightInPx
val imageHeightBiggerThanScreenHeight = options.outHeight > optimalImageHeight
return imageHeightIsBiggerThanWidth && imageHeightBiggerThanScreenHeight
}
@@ -300,9 +300,8 @@ object ImageUtil {
val imageHeight = outHeight
val imageWidth = outWidth
val splitHeight = getDisplayMaxHeightInPx * 2
// -1 so it doesn't try to split when imageHeight = splitHeight
val partCount = (imageHeight - 1) / splitHeight + 1
// -1 so it doesn't try to split when imageHeight = optimalImageHeight
val partCount = (imageHeight - 1) / optimalImageHeight + 1
val optimalSplitHeight = imageHeight / partCount
logcat {
@@ -316,15 +315,15 @@ object ImageUtil {
if (isNotEmpty() && imageHeight <= last().bottomOffset) break
val topOffset = index * optimalSplitHeight
var outputImageHeight = min(optimalSplitHeight, imageHeight - topOffset)
var splitHeight = min(optimalSplitHeight, imageHeight - topOffset)
val remainingHeight = imageHeight - (topOffset + outputImageHeight)
val remainingHeight = imageHeight - (topOffset + splitHeight)
// If remaining height is smaller or equal to 1/10th of
// optimal split height then include it in current page
if (remainingHeight <= (optimalSplitHeight / 10)) {
outputImageHeight += remainingHeight
splitHeight += remainingHeight
}
add(SplitData(index, topOffset, outputImageHeight, imageWidth))
add(SplitData(index, topOffset, splitHeight, imageWidth))
}
}
}
@@ -578,6 +577,8 @@ object ImageUtil {
}
}
private val optimalImageHeight = getDisplayMaxHeightInPx * 2
// Android doesn't include some mappings
private val SUPPLEMENTARY_MIMETYPE_MAPPING = mapOf(
// https://issuetracker.google.com/issues/182703810