|
@@ -4,6 +4,7 @@ import android.view.View
|
|
import android.view.ViewGroup
|
|
import android.view.ViewGroup
|
|
import androidx.viewpager.widget.PagerAdapter
|
|
import androidx.viewpager.widget.PagerAdapter
|
|
import eu.kanade.tachiyomi.ui.reader.model.ChapterTransition
|
|
import eu.kanade.tachiyomi.ui.reader.model.ChapterTransition
|
|
|
|
+import eu.kanade.tachiyomi.ui.reader.model.ReaderChapter
|
|
import eu.kanade.tachiyomi.ui.reader.model.ReaderPage
|
|
import eu.kanade.tachiyomi.ui.reader.model.ReaderPage
|
|
import eu.kanade.tachiyomi.ui.reader.model.ViewerChapters
|
|
import eu.kanade.tachiyomi.ui.reader.model.ViewerChapters
|
|
import eu.kanade.tachiyomi.widget.ViewPagerAdapter
|
|
import eu.kanade.tachiyomi.widget.ViewPagerAdapter
|
|
@@ -28,7 +29,7 @@ class PagerViewerAdapter(private val viewer: PagerViewer) : ViewPagerAdapter() {
|
|
* next/previous chapter to allow seamless transitions and inverting the pages if the viewer
|
|
* next/previous chapter to allow seamless transitions and inverting the pages if the viewer
|
|
* has R2L direction.
|
|
* has R2L direction.
|
|
*/
|
|
*/
|
|
- fun setChapters(chapters: ViewerChapters) {
|
|
|
|
|
|
+ fun setChapters(chapters: ViewerChapters, forceTransition: Boolean) {
|
|
val newItems = mutableListOf<Any>()
|
|
val newItems = mutableListOf<Any>()
|
|
|
|
|
|
// Add previous chapter pages and transition.
|
|
// Add previous chapter pages and transition.
|
|
@@ -40,7 +41,11 @@ class PagerViewerAdapter(private val viewer: PagerViewer) : ViewPagerAdapter() {
|
|
newItems.addAll(prevPages.takeLast(2))
|
|
newItems.addAll(prevPages.takeLast(2))
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- newItems.add(ChapterTransition.Prev(chapters.currChapter, chapters.prevChapter))
|
|
|
|
|
|
+
|
|
|
|
+ // Skip transition page if the chapter is loaded & current page is not a transition page
|
|
|
|
+ if (forceTransition || chapters.prevChapter?.state !is ReaderChapter.State.Loaded) {
|
|
|
|
+ newItems.add(ChapterTransition.Prev(chapters.currChapter, chapters.prevChapter))
|
|
|
|
+ }
|
|
|
|
|
|
// Add current chapter.
|
|
// Add current chapter.
|
|
val currPages = chapters.currChapter.pages
|
|
val currPages = chapters.currChapter.pages
|
|
@@ -50,7 +55,13 @@ class PagerViewerAdapter(private val viewer: PagerViewer) : ViewPagerAdapter() {
|
|
|
|
|
|
// Add next chapter transition and pages.
|
|
// Add next chapter transition and pages.
|
|
nextTransition = ChapterTransition.Next(chapters.currChapter, chapters.nextChapter)
|
|
nextTransition = ChapterTransition.Next(chapters.currChapter, chapters.nextChapter)
|
|
- .also { newItems.add(it) }
|
|
|
|
|
|
+ .also {
|
|
|
|
+ if (forceTransition ||
|
|
|
|
+ chapters.nextChapter?.state !is ReaderChapter.State.Loaded) {
|
|
|
|
+ newItems.add(it)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
if (chapters.nextChapter != null) {
|
|
if (chapters.nextChapter != null) {
|
|
// Add at most two pages, because this chapter will be selected before the user can
|
|
// Add at most two pages, because this chapter will be selected before the user can
|
|
// swap more pages.
|
|
// swap more pages.
|