mirror of
https://github.com/mihonapp/mihon.git
synced 2025-11-16 05:57:29 +01:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user