Fix next chapter button occasionally jumping to the last page of the current chapter (mihonapp/mihon#1920)

(cherry picked from commit 941dde341eb11703eadae543f351c9284617541c)
This commit is contained in:
perokhe 2025-03-27 08:25:25 -06:00 committed by Cuong-Tran
parent a9cc060dc8
commit b5177c5930
No known key found for this signature in database
GPG key ID: 733AA7624B9315C2
2 changed files with 7 additions and 5 deletions

View file

@ -16,6 +16,7 @@ The format is a modified version of [Keep a Changelog](https://keepachangelog.co
### Fixes
- Fix Bangumi search results including novels ([@MajorTanya](https://github.com/MajorTanya)) ([#1885](https://github.com/mihonapp/mihon/pull/1885))
- Fix next chapter button occasionally jumping to the last page of the current chapter ([@perokhe](https://github.com/perokhe)) ([#1920](https://github.com/mihonapp/mihon/pull/1920))
## [v0.18.0] - 2025-03-20
### Added

View file

@ -116,11 +116,7 @@ abstract class PagerViewer(
pager.offscreenPageLimit = 1
pager.id = R.id.reader_pager
pager.adapter = adapter
pager.addOnPageChangeListener(
// SY -->
pagerListener,
// SY <--
)
pager.addOnPageChangeListener(pagerListener)
pager.tapListener = { event ->
val viewPosition = IntArray(2)
pager.getLocationOnScreen(viewPosition)
@ -302,6 +298,9 @@ abstract class PagerViewer(
* Sets the active [chapters] on this pager.
*/
private fun setChaptersInternal(chapters: ViewerChapters) {
// Remove listener so the change in item doesn't trigger it
pager.removeOnPageChangeListener(pagerListener)
val forceTransition =
config.alwaysShowChapterTransition ||
adapter.joinedItems.getOrNull(pager.currentItem)?.first is ChapterTransition
@ -314,6 +313,8 @@ abstract class PagerViewer(
moveToPage(pages[min(chapters.currChapter.requestedPage, pages.lastIndex)])
pager.isVisible = true
}
pager.addOnPageChangeListener(pagerListener)
}
/**