Add all pages of adjacent chapters in the UI instead of only the first or last three (#2995)
This commit is contained in:
@@ -30,6 +30,7 @@ The format is a modified version of [Keep a Changelog](https://keepachangelog.co
|
|||||||
### Changed
|
### Changed
|
||||||
- Update tracker icons ([@AntsyLich](https://github.com/AntsyLich)) ([#2773](https://github.com/mihonapp/mihon/pull/2773))
|
- Update tracker icons ([@AntsyLich](https://github.com/AntsyLich)) ([#2773](https://github.com/mihonapp/mihon/pull/2773))
|
||||||
- Add a small increment to chapter number before comparison to fix progress sync issues for Suwayomi ([@cpiber](https://github.com/cpiber)) ([#2657](https://github.com/mihonapp/mihon/pull/2675))
|
- Add a small increment to chapter number before comparison to fix progress sync issues for Suwayomi ([@cpiber](https://github.com/cpiber)) ([#2657](https://github.com/mihonapp/mihon/pull/2675))
|
||||||
|
- Add all pages of adjacent chapters in the UI instead of only the first or last three ([@AntsyLich](https://github.com/AntsyLich)) ([#2995](https://github.com/mihonapp/mihon/pull/2995))
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- Fix reader tap zones triggering after scrolling is stopped by tapping ([@NGB-Was-Taken](https://github.com/NGB-Was-Taken)) ([#2680](https://github.com/mihonapp/mihon/pull/2680))
|
- Fix reader tap zones triggering after scrolling is stopped by tapping ([@NGB-Was-Taken](https://github.com/NGB-Was-Taken)) ([#2680](https://github.com/mihonapp/mihon/pull/2680))
|
||||||
|
|||||||
@@ -51,15 +51,8 @@ class PagerViewerAdapter(private val viewer: PagerViewer) : ViewPagerAdapter() {
|
|||||||
val prevHasMissingChapters = calculateChapterGap(chapters.currChapter, chapters.prevChapter) > 0
|
val prevHasMissingChapters = calculateChapterGap(chapters.currChapter, chapters.prevChapter) > 0
|
||||||
val nextHasMissingChapters = calculateChapterGap(chapters.nextChapter, chapters.currChapter) > 0
|
val nextHasMissingChapters = calculateChapterGap(chapters.nextChapter, chapters.currChapter) > 0
|
||||||
|
|
||||||
// Add previous chapter pages and transition.
|
// Add previous chapter pages and transition
|
||||||
if (chapters.prevChapter != null) {
|
chapters.prevChapter?.pages?.let(newItems::addAll)
|
||||||
// We only need to add the last few pages of the previous chapter, because it'll be
|
|
||||||
// selected as the current chapter when one of those pages is selected.
|
|
||||||
val prevPages = chapters.prevChapter.pages
|
|
||||||
if (prevPages != null) {
|
|
||||||
newItems.addAll(prevPages.takeLast(2))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Skip transition page if the chapter is loaded & current page is not a transition page
|
// Skip transition page if the chapter is loaded & current page is not a transition page
|
||||||
if (prevHasMissingChapters || forceTransition || chapters.prevChapter?.state !is ReaderChapter.State.Loaded) {
|
if (prevHasMissingChapters || forceTransition || chapters.prevChapter?.state !is ReaderChapter.State.Loaded) {
|
||||||
@@ -101,14 +94,7 @@ class PagerViewerAdapter(private val viewer: PagerViewer) : ViewPagerAdapter() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chapters.nextChapter != null) {
|
chapters.nextChapter?.pages?.let(newItems::addAll)
|
||||||
// Add at most two pages, because this chapter will be selected before the user can
|
|
||||||
// swap more pages.
|
|
||||||
val nextPages = chapters.nextChapter.pages
|
|
||||||
if (nextPages != null) {
|
|
||||||
newItems.addAll(nextPages.take(2))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Resets double-page splits, else insert pages get misplaced
|
// Resets double-page splits, else insert pages get misplaced
|
||||||
items.filterIsInstance<InsertPage>().also { items.removeAll(it) }
|
items.filterIsInstance<InsertPage>().also { items.removeAll(it) }
|
||||||
|
|||||||
@@ -43,14 +43,7 @@ class WebtoonAdapter(val viewer: WebtoonViewer) : RecyclerView.Adapter<RecyclerV
|
|||||||
val nextHasMissingChapters = calculateChapterGap(chapters.nextChapter, chapters.currChapter) > 0
|
val nextHasMissingChapters = calculateChapterGap(chapters.nextChapter, chapters.currChapter) > 0
|
||||||
|
|
||||||
// Add previous chapter pages and transition.
|
// Add previous chapter pages and transition.
|
||||||
if (chapters.prevChapter != null) {
|
chapters.prevChapter?.pages?.let(newItems::addAll)
|
||||||
// We only need to add the last few pages of the previous chapter, because it'll be
|
|
||||||
// selected as the current chapter when one of those pages is selected.
|
|
||||||
val prevPages = chapters.prevChapter.pages
|
|
||||||
if (prevPages != null) {
|
|
||||||
newItems.addAll(prevPages.takeLast(2))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Skip transition page if the chapter is loaded & current page is not a transition page
|
// Skip transition page if the chapter is loaded & current page is not a transition page
|
||||||
if (prevHasMissingChapters || forceTransition || chapters.prevChapter?.state !is ReaderChapter.State.Loaded) {
|
if (prevHasMissingChapters || forceTransition || chapters.prevChapter?.state !is ReaderChapter.State.Loaded) {
|
||||||
@@ -70,14 +63,7 @@ class WebtoonAdapter(val viewer: WebtoonViewer) : RecyclerView.Adapter<RecyclerV
|
|||||||
newItems.add(ChapterTransition.Next(chapters.currChapter, chapters.nextChapter))
|
newItems.add(ChapterTransition.Next(chapters.currChapter, chapters.nextChapter))
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chapters.nextChapter != null) {
|
chapters.nextChapter?.pages?.let(newItems::addAll)
|
||||||
// Add at most two pages, because this chapter will be selected before the user can
|
|
||||||
// swap more pages.
|
|
||||||
val nextPages = chapters.nextChapter.pages
|
|
||||||
if (nextPages != null) {
|
|
||||||
newItems.addAll(nextPages.take(2))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
updateItems(newItems)
|
updateItems(newItems)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user