show chapter toolbar when changing chapters with buffer page off

This commit is contained in:
Jay 2020-03-21 01:18:15 -04:00
parent 13836f0ae3
commit 2e3aa6e39e
4 changed files with 20 additions and 8 deletions

View File

@ -492,7 +492,7 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>(),
*/
@SuppressLint("SetTextI18n")
fun onPageSelected(page: ReaderPage) {
presenter.onPageSelected(page)
val newChapter = presenter.onPageSelected(page)
val pages = page.chapter.pages ?: return
// Set bottom page number
@ -507,6 +507,10 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>(),
left_page_text.text = "${pages.size}"
}
if (newChapter && config?.showNewChapter == false) {
systemUi?.show()
}
// Set seekbar progress
page_seekbar.max = pages.lastIndex
page_seekbar.progress = page.index
@ -679,6 +683,8 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>(),
*/
private var customFilterColorSubscription: Subscription? = null
var showNewChapter = false
/**
* Initializes the reader subscriptions.
*/
@ -715,6 +721,9 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>(),
subscriptions += preferences.colorFilterMode().asObservable()
.subscribe { setColorFilter(preferences.colorFilter().getOrDefault()) }
subscriptions += preferences.alwaysShowChapterTransition().asObservable()
.subscribe { showNewChapter = it }
}
/**

View File

@ -24,9 +24,6 @@ import eu.kanade.tachiyomi.ui.reader.model.ReaderPage
import eu.kanade.tachiyomi.ui.reader.model.ViewerChapters
import eu.kanade.tachiyomi.util.storage.DiskUtil
import eu.kanade.tachiyomi.util.system.ImageUtil
import java.io.File
import java.util.Date
import java.util.concurrent.TimeUnit
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
@ -39,6 +36,9 @@ import rx.schedulers.Schedulers
import timber.log.Timber
import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
import java.io.File
import java.util.Date
import java.util.concurrent.TimeUnit
/**
* Presenter used by the activity to perform background operations.
@ -318,8 +318,8 @@ class ReaderPresenter(
* read, update tracking services, enqueue downloaded chapter deletion, and updating the active chapter if this
* [page]'s chapter is different from the currently active.
*/
fun onPageSelected(page: ReaderPage) {
val currentChapters = viewerChaptersRelay.value ?: return
fun onPageSelected(page: ReaderPage): Boolean {
val currentChapters = viewerChaptersRelay.value ?: return false
val selectedChapter = page.chapter
@ -337,7 +337,9 @@ class ReaderPresenter(
Timber.d("Setting ${selectedChapter.chapter.url} as active")
onChapterChanged(currentChapters.currChapter, selectedChapter)
loadNewChapter(selectedChapter)
return true
}
return false
}
/**

View File

@ -187,7 +187,8 @@ abstract class PagerViewer(val activity: ReaderActivity) : BaseViewer {
*/
private fun setChaptersInternal(chapters: ViewerChapters) {
Timber.d("setChaptersInternal")
var forceTransition = config.alwaysShowChapterTransition || adapter.items.getOrNull(pager.currentItem) is ChapterTransition
val forceTransition = config.alwaysShowChapterTransition || adapter.items.getOrNull(pager
.currentItem) is ChapterTransition
adapter.setChapters(chapters, forceTransition)
// Layout the pager once a chapter is being set

View File

@ -174,7 +174,7 @@ class WebtoonViewer(val activity: ReaderActivity) : BaseViewer {
*/
override fun setChapters(chapters: ViewerChapters) {
Timber.d("setChapters")
var forceTransition = config.alwaysShowChapterTransition || currentPage is ChapterTransition
val forceTransition = config.alwaysShowChapterTransition || currentPage is ChapterTransition
adapter.setChapters(chapters, forceTransition)
if (recycler.visibility == View.GONE) {