|
@@ -9,6 +9,7 @@ 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.ViewerChapters
|
|
|
+import eu.kanade.tachiyomi.ui.reader.viewer.MissingChapters
|
|
|
|
|
|
/**
|
|
|
* RecyclerView Adapter used by this [viewer] to where [ViewerChapters] updates are posted.
|
|
@@ -29,6 +30,10 @@ class WebtoonAdapter(val viewer: WebtoonViewer) : RecyclerView.Adapter<RecyclerV
|
|
|
fun setChapters(chapters: ViewerChapters, forceTransition: Boolean) {
|
|
|
val newItems = mutableListOf<Any>()
|
|
|
|
|
|
+ // Forces chapter transition if there is missing chapters
|
|
|
+ val prevHasMissingChapters = if (chapters.prevChapter != null) MissingChapters.hasMissingChapters(chapters.currChapter.chapter, chapters.prevChapter.chapter) else false
|
|
|
+ val nextHasMissingChapters = if (chapters.nextChapter != null) MissingChapters.hasMissingChapters(chapters.nextChapter.chapter, chapters.currChapter.chapter) else false
|
|
|
+
|
|
|
// Add previous chapter pages and transition.
|
|
|
if (chapters.prevChapter != null) {
|
|
|
// We only need to add the last few pages of the previous chapter, because it'll be
|
|
@@ -40,7 +45,7 @@ class WebtoonAdapter(val viewer: WebtoonViewer) : RecyclerView.Adapter<RecyclerV
|
|
|
}
|
|
|
|
|
|
// Skip transition page if the chapter is loaded & current page is not a transition page
|
|
|
- if (forceTransition || chapters.prevChapter?.state !is ReaderChapter.State.Loaded) {
|
|
|
+ if (prevHasMissingChapters || forceTransition || chapters.prevChapter?.state !is ReaderChapter.State.Loaded) {
|
|
|
newItems.add(ChapterTransition.Prev(chapters.currChapter, chapters.prevChapter))
|
|
|
}
|
|
|
|
|
@@ -53,7 +58,7 @@ class WebtoonAdapter(val viewer: WebtoonViewer) : RecyclerView.Adapter<RecyclerV
|
|
|
currentChapter = chapters.currChapter
|
|
|
|
|
|
// Add next chapter transition and pages.
|
|
|
- if (forceTransition || chapters.nextChapter?.state !is ReaderChapter.State.Loaded) {
|
|
|
+ if (nextHasMissingChapters || forceTransition || chapters.nextChapter?.state !is ReaderChapter.State.Loaded) {
|
|
|
newItems.add(ChapterTransition.Next(chapters.currChapter, chapters.nextChapter))
|
|
|
}
|
|
|
|