mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
fix(reader): Return the original image if split bitmap failed
This commit is contained in:
parent
03043ef01b
commit
c1dd80bd71
1 changed files with 18 additions and 6 deletions
|
@ -600,6 +600,8 @@ class PagerPageHolder(
|
||||||
scope.launchUI { progressIndicator.completeAndFadeOut() }
|
scope.launchUI { progressIndicator.completeAndFadeOut() }
|
||||||
return imageSource
|
return imageSource
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Try to split
|
||||||
if (page.longPage == true && viewer.config.splitPages) {
|
if (page.longPage == true && viewer.config.splitPages) {
|
||||||
val imageBitmap = try {
|
val imageBitmap = try {
|
||||||
BitmapFactory.decodeStream(imageSource.peek().inputStream())
|
BitmapFactory.decodeStream(imageSource.peek().inputStream())
|
||||||
|
@ -608,17 +610,24 @@ class PagerPageHolder(
|
||||||
return imageSource
|
return imageSource
|
||||||
}
|
}
|
||||||
val isLTR = (viewer !is R2LPagerViewer).xor(viewer.config.invertDoublePages)
|
val isLTR = (viewer !is R2LPagerViewer).xor(viewer.config.invertDoublePages)
|
||||||
return ImageUtil.splitBitmap(imageBitmap, (page.firstHalf == false).xor(!isLTR)) {
|
return try {
|
||||||
scope.launchUI {
|
ImageUtil.splitBitmap(imageBitmap, (page.firstHalf == false).xor(!isLTR)) {
|
||||||
if (it == 100) {
|
scope.launchUI {
|
||||||
progressIndicator.completeAndFadeOut()
|
if (it == 100) {
|
||||||
} else {
|
progressIndicator.completeAndFadeOut()
|
||||||
progressIndicator.setProgress(it)
|
} else {
|
||||||
|
progressIndicator.setProgress(it)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (e: NullPointerException) {
|
||||||
|
Logger.e(e) { "Cannot split page" }
|
||||||
|
imageSource
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (imageSource2 == null) {
|
if (imageSource2 == null) {
|
||||||
|
// Detect if page is wide enough to be split
|
||||||
if (viewer.config.splitPages && page.longPage == null) {
|
if (viewer.config.splitPages && page.longPage == null) {
|
||||||
val imageBitmap = try {
|
val imageBitmap = try {
|
||||||
BitmapFactory.decodeStream(imageSource.peek().inputStream())
|
BitmapFactory.decodeStream(imageSource.peek().inputStream())
|
||||||
|
@ -663,7 +672,10 @@ class PagerPageHolder(
|
||||||
}
|
}
|
||||||
return supportHingeIfThere(imageSource)
|
return supportHingeIfThere(imageSource)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Too wide to be merged
|
||||||
if (page.fullPage == true) return supportHingeIfThere(imageSource)
|
if (page.fullPage == true) return supportHingeIfThere(imageSource)
|
||||||
|
|
||||||
val imageBitmap = try {
|
val imageBitmap = try {
|
||||||
BitmapFactory.decodeStream(imageSource.peek().inputStream())
|
BitmapFactory.decodeStream(imageSource.peek().inputStream())
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue