Fix double page progress when changing orientation (#799)

* Fix double page when changing orientation

* Fix requested page, when device config changes when app is in BG

* Cleanup on save reader logic
This commit is contained in:
Jays2Kings 2023-03-15 17:40:52 -04:00 committed by GitHub
parent e8f9550211
commit 520846c75e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 0 deletions

View File

@ -614,6 +614,9 @@ class ReaderViewModel(
* If incognito mode isn't on or has at least 1 tracker
*/
private suspend fun saveChapterProgress(readerChapter: ReaderChapter) {
// SY -->
readerChapter.requestedPage = readerChapter.chapter.last_page_read
// SY <--
if (!incognitoMode || hasTrackers) {
val chapter = readerChapter.chapter
getCurrentChapter()?.requestedPage = chapter.last_page_read

View File

@ -1,6 +1,7 @@
package eu.kanade.tachiyomi.ui.reader.viewer.pager
import android.content.Context
import android.os.Parcelable
import android.view.HapticFeedbackConstants
import android.view.KeyEvent
import android.view.MotionEvent
@ -27,6 +28,18 @@ open class Pager(
*/
var longTapListener: ((MotionEvent) -> Boolean)? = null
// SY -->
var isRestoring = false
override fun onRestoreInstanceState(state: Parcelable?) {
isRestoring = true
val currentItem = currentItem
super.onRestoreInstanceState(state)
setCurrentItem(currentItem, false)
isRestoring = false
}
// SY <--
/**
* Gesture listener that implements tap and long tap events.
*/

View File

@ -86,6 +86,9 @@ abstract class PagerViewer(val activity: ReaderActivity) : BaseViewer {
private val pagerListener = object : ViewPager.SimpleOnPageChangeListener() {
override fun onPageSelected(position: Int) {
// SY -->
if (pager.isRestoring) return
// SY <--
if (activity.isScrollingThroughPages.not()) {
activity.hideMenu()
}