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
* page is not found.
*/
fun moveToPageIndex(index: Int) {
fun moveToPageIndex(index: Int, animated: Boolean = true) {
val viewer = viewer ?: return
val currentChapter = presenter.getCurrentChapter() ?: return
val page = currentChapter.pages?.getOrNull(index) ?: return
viewer.moveToPage(page)
viewer.moveToPage(page, animated)
}
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.system.ImageUtil
import eu.kanade.tachiyomi.util.system.executeOnIO
import eu.kanade.tachiyomi.util.system.launchUI
import eu.kanade.tachiyomi.util.system.withUIContext
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
@ -412,12 +413,15 @@ class ReaderPresenter(
Timber.d("Loading ${chapter.url}")
activeChapterSubscription?.unsubscribe()
val lastPage = if (chapter.pages_left <= 1) 0 else chapter.last_page_read
activeChapterSubscription = getLoadObservable(loader, ReaderChapter(chapter))
.doOnSubscribe { isLoadingAdjacentChapterRelay.call(true) }
.doOnUnsubscribe { isLoadingAdjacentChapterRelay.call(false) }
.subscribeFirst(
{ view, _ ->
view.moveToPageIndex(0)
scope.launchUI {
view.moveToPageIndex(lastPage, false)
}
view.refreshChapters()
},
{ _, _ ->

View File

@ -29,7 +29,7 @@ interface BaseViewer {
/**
* 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.

View File

@ -273,12 +273,12 @@ abstract class PagerViewer(val activity: ReaderActivity) : BaseViewer {
/**
* 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}")
val position = adapter.joinedItems.indexOfFirst { it.first == page || it.second == page }
if (position != -1) {
val currentPosition = pager.currentItem
pager.setCurrentItem(position, true)
pager.setCurrentItem(position, animated)
// manually call onPageChange since ViewPager listener is not triggered in this case
if (currentPosition == 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].
*/
override fun moveToPage(page: ReaderPage) {
override fun moveToPage(page: ReaderPage, animated: Boolean) {
Timber.d("moveToPage")
val position = adapter.items.indexOf(page)
if (position != -1) {