Fix "Landscape zoom" and "Navigate to pan" for split images (#6647)

* fix: getPageHolder would always return the first split, as they share the same index

* split pages have the same number, we need an extra check to know whether we move forward or back
This commit is contained in:
Gauthier 2022-02-18 11:09:03 +08:00 committed by GitHub
parent a8ad19a89d
commit 2f07f226b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -161,7 +161,7 @@ abstract class PagerViewer(val activity: ReaderActivity) : BaseViewer {
private fun getPageHolder(page: ReaderPage): PagerPageHolder? = private fun getPageHolder(page: ReaderPage): PagerPageHolder? =
pager.children pager.children
.filterIsInstance(PagerPageHolder::class.java) .filterIsInstance(PagerPageHolder::class.java)
.firstOrNull { it.item.index == page.index } .firstOrNull { it.item == page }
/** /**
* Called when a new page (either a [ReaderPage] or [ChapterTransition]) is marked as active * Called when a new page (either a [ReaderPage] or [ChapterTransition]) is marked as active
@ -171,8 +171,15 @@ abstract class PagerViewer(val activity: ReaderActivity) : BaseViewer {
if (page != null && currentPage != page) { if (page != null && currentPage != page) {
val allowPreload = checkAllowPreload(page as? ReaderPage) val allowPreload = checkAllowPreload(page as? ReaderPage)
val forward = when { val forward = when {
currentPage is ReaderPage && page is ReaderPage -> currentPage is ReaderPage && page is ReaderPage -> {
// if both pages have the same number, it's a split page with an InsertPage
if (page.number == (currentPage as ReaderPage).number) {
// the InsertPage is always the second in the reading direction
page is InsertPage
} else {
page.number > (currentPage as ReaderPage).number page.number > (currentPage as ReaderPage).number
}
}
currentPage is ChapterTransition.Prev && page is ReaderPage -> currentPage is ChapterTransition.Prev && page is ReaderPage ->
false false
else -> true else -> true