From f1ab34e27cbd8f26f87e34238af0863d4650b960 Mon Sep 17 00:00:00 2001 From: CVIUS <84634607+CVIUS@users.noreply.github.com> Date: Sat, 14 May 2022 20:51:04 +0800 Subject: [PATCH] Save reader progress when activity is paused (#7121) --- .../java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt | 5 +++++ .../java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt index 9053864d8..157ee3c96 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt @@ -231,6 +231,11 @@ class ReaderActivity : BaseRxActivity() { super.onSaveInstanceState(outState) } + override fun onPause() { + presenter.saveProgress() + super.onPause() + } + /** * Set menu visibility again on activity resume to apply immersive mode again if needed. * Helps with rotations. diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt index 3d79e877d..2d9c1c67f 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt @@ -465,6 +465,10 @@ class ReaderPresenter( } } + fun saveProgress() { + getCurrentChapter()?.let { onChapterChanged(it) } + } + /** * Called from the activity to preload the given [chapter]. */