Old functionality returns on demand
This commit is contained in:
Jays2Kings 2021-05-06 15:59:45 -04:00
parent 3ad24840a3
commit 091cc0acb2
5 changed files with 11 additions and 7 deletions

View File

@ -1026,11 +1026,11 @@ class ReaderActivity :
* Moves the viewer to the given page [index]. It does nothing if the viewer is null or the * Moves the viewer to the given page [index]. It does nothing if the viewer is null or the
* page is not found. * page is not found.
*/ */
fun moveToPageIndex(index: Int) { fun moveToPageIndex(index: Int, animated: Boolean = true) {
val viewer = viewer ?: return val viewer = viewer ?: return
val currentChapter = presenter.getCurrentChapter() ?: return val currentChapter = presenter.getCurrentChapter() ?: return
val page = currentChapter.pages?.getOrNull(index) ?: return val page = currentChapter.pages?.getOrNull(index) ?: return
viewer.moveToPage(page) viewer.moveToPage(page, animated)
} }
fun refreshChapters() { fun refreshChapters() {

View File

@ -34,6 +34,7 @@ import eu.kanade.tachiyomi.util.chapter.syncChaptersWithSource
import eu.kanade.tachiyomi.util.storage.DiskUtil import eu.kanade.tachiyomi.util.storage.DiskUtil
import eu.kanade.tachiyomi.util.system.ImageUtil import eu.kanade.tachiyomi.util.system.ImageUtil
import eu.kanade.tachiyomi.util.system.executeOnIO import eu.kanade.tachiyomi.util.system.executeOnIO
import eu.kanade.tachiyomi.util.system.launchUI
import eu.kanade.tachiyomi.util.system.withUIContext import eu.kanade.tachiyomi.util.system.withUIContext
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
@ -412,12 +413,15 @@ class ReaderPresenter(
Timber.d("Loading ${chapter.url}") Timber.d("Loading ${chapter.url}")
activeChapterSubscription?.unsubscribe() activeChapterSubscription?.unsubscribe()
val lastPage = if (chapter.pages_left <= 1) 0 else chapter.last_page_read
activeChapterSubscription = getLoadObservable(loader, ReaderChapter(chapter)) activeChapterSubscription = getLoadObservable(loader, ReaderChapter(chapter))
.doOnSubscribe { isLoadingAdjacentChapterRelay.call(true) } .doOnSubscribe { isLoadingAdjacentChapterRelay.call(true) }
.doOnUnsubscribe { isLoadingAdjacentChapterRelay.call(false) } .doOnUnsubscribe { isLoadingAdjacentChapterRelay.call(false) }
.subscribeFirst( .subscribeFirst(
{ view, _ -> { view, _ ->
view.moveToPageIndex(0) scope.launchUI {
view.moveToPageIndex(lastPage, false)
}
view.refreshChapters() view.refreshChapters()
}, },
{ _, _ -> { _, _ ->

View File

@ -29,7 +29,7 @@ interface BaseViewer {
/** /**
* Tells this viewer to move to the given [page]. * Tells this viewer to move to the given [page].
*/ */
fun moveToPage(page: ReaderPage) fun moveToPage(page: ReaderPage, animated: Boolean = true)
/** /**
* Moves to the next page. * Moves to the next page.

View File

@ -273,12 +273,12 @@ abstract class PagerViewer(val activity: ReaderActivity) : BaseViewer {
/** /**
* Tells this viewer to move to the given [page]. * Tells this viewer to move to the given [page].
*/ */
override fun moveToPage(page: ReaderPage) { override fun moveToPage(page: ReaderPage, animated: Boolean) {
Timber.d("moveToPage ${page.number}") Timber.d("moveToPage ${page.number}")
val position = adapter.joinedItems.indexOfFirst { it.first == page || it.second == page } val position = adapter.joinedItems.indexOfFirst { it.first == page || it.second == page }
if (position != -1) { if (position != -1) {
val currentPosition = pager.currentItem val currentPosition = pager.currentItem
pager.setCurrentItem(position, true) pager.setCurrentItem(position, animated)
// manually call onPageChange since ViewPager listener is not triggered in this case // manually call onPageChange since ViewPager listener is not triggered in this case
if (currentPosition == position) { if (currentPosition == position) {
onPageChange(position) onPageChange(position)

View File

@ -236,7 +236,7 @@ class WebtoonViewer(val activity: ReaderActivity, val hasMargins: Boolean = fals
/** /**
* Tells this viewer to move to the given [page]. * Tells this viewer to move to the given [page].
*/ */
override fun moveToPage(page: ReaderPage) { override fun moveToPage(page: ReaderPage, animated: Boolean) {
Timber.d("moveToPage") Timber.d("moveToPage")
val position = adapter.items.indexOf(page) val position = adapter.items.indexOf(page)
if (position != -1) { if (position != -1) {