From 884d135e129f04d0509503659457a376fa59ab68 Mon Sep 17 00:00:00 2001 From: gedoor Date: Mon, 1 Mar 2021 09:22:18 +0800 Subject: [PATCH] =?UTF-8?q?=E9=98=85=E8=AF=BB=E9=A1=B5=E9=9D=A2=E5=81=9C?= =?UTF-8?q?=E7=95=9910=E5=88=86=E9=92=9F=E4=B9=8B=E5=90=8E=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E5=A4=87=E4=BB=BD=E8=BF=9B=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/service/help/ReadBook.kt | 2 +- .../io/legado/app/ui/book/read/ReadBookActivity.kt | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/io/legado/app/service/help/ReadBook.kt b/app/src/main/java/io/legado/app/service/help/ReadBook.kt index 5b6f33b6e..ab07ec9f2 100644 --- a/app/src/main/java/io/legado/app/service/help/ReadBook.kt +++ b/app/src/main/java/io/legado/app/service/help/ReadBook.kt @@ -186,7 +186,7 @@ object ReadBook { fun skipToPage(index: Int, success: (() -> Unit)? = null) { durChapterPos = curTextChapter?.getReadLength(index) ?: index - callBack?.upContent() { + callBack?.upContent { success?.invoke() } curPageChanged() diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt index 051cf7ab7..d51321812 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt @@ -81,9 +81,14 @@ class ReadBookActivity : ReadBookBaseActivity(), override val isInitFinish: Boolean get() = viewModel.isInitFinish override val isScroll: Boolean get() = binding.readView.isScroll private val mHandler = Handler(Looper.getMainLooper()) - private val keepScreenRunnable: Runnable = - Runnable { keepScreenOn(window, false) } - private val autoPageRunnable: Runnable = Runnable { autoPagePlus() } + private val keepScreenRunnable = Runnable { keepScreenOn(window, false) } + private val autoPageRunnable = Runnable { autoPagePlus() } + private val backupRunnable = Runnable { + if (!BuildConfig.DEBUG) { + ReadBook.uploadProgress() + Backup.autoBack(this) + } + } override var autoPageProgress = 0 override var isAutoPage = false private var screenTimeOut: Long = 0 @@ -129,6 +134,7 @@ class ReadBookActivity : ReadBookBaseActivity(), override fun onPause() { super.onPause() + mHandler.removeCallbacks(backupRunnable) ReadBook.saveRead() timeBatteryReceiver?.let { unregisterReceiver(it) @@ -571,6 +577,7 @@ class ReadBookActivity : ReadBookBaseActivity(), launch { binding.readMenu.setSeekPage(ReadBook.durPageIndex()) } + mHandler.postDelayed(backupRunnable, 600000) } /**