阅读页面停留10分钟之后自动备份进度

pull/878/head
gedoor 4 years ago
parent 38f1a90e84
commit 884d135e12
  1. 2
      app/src/main/java/io/legado/app/service/help/ReadBook.kt
  2. 13
      app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.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()

@ -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)
}
/**

Loading…
Cancel
Save