mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-20 06:39:20 +01:00
parent
3ad24840a3
commit
091cc0acb2
@ -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() {
|
||||||
|
@ -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()
|
||||||
},
|
},
|
||||||
{ _, _ ->
|
{ _, _ ->
|
||||||
|
@ -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.
|
||||||
|
@ -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)
|
||||||
|
@ -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) {
|
||||||
|
Loading…
Reference in New Issue
Block a user