只弹一次恢复进度对话框

pull/2404/head
Xwite 2 years ago
parent d794ee5b6a
commit 16b20edd4c
  1. 16
      app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt

@ -167,6 +167,9 @@ class ReadBookActivity : BaseReadBookActivity(),
private val nextPageRunnable by lazy { Runnable { mouseWheelPage(PageDirection.NEXT) } } private val nextPageRunnable by lazy { Runnable { mouseWheelPage(PageDirection.NEXT) } }
private val prevPageRunnable by lazy { Runnable { mouseWheelPage(PageDirection.PREV) } } private val prevPageRunnable by lazy { Runnable { mouseWheelPage(PageDirection.PREV) } }
//恢复跳转前进度对话框的交互结果
private var confirmRestoreProcess: Boolean? = null
@SuppressLint("ClickableViewAccessibility") @SuppressLint("ClickableViewAccessibility")
override fun onActivityCreated(savedInstanceState: Bundle?) { override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState) super.onActivityCreated(savedInstanceState)
@ -497,7 +500,8 @@ class ReadBookActivity : BaseReadBookActivity(),
restoreLastBookProcess() restoreLastBookProcess()
return true return true
} }
if (ReadBook.lastBookPress != null) { //拦截返回供恢复阅读进度
if (ReadBook.lastBookPress != null && confirmRestoreProcess != false) {
restoreLastBookProcess() restoreLastBookProcess()
return true return true
} }
@ -997,13 +1001,23 @@ class ReadBookActivity : BaseReadBookActivity(),
/* 恢复到 全文搜索/进度条跳转前的位置 */ /* 恢复到 全文搜索/进度条跳转前的位置 */
private fun restoreLastBookProcess() { private fun restoreLastBookProcess() {
// 默认提示恢复 // 默认提示恢复
if (confirmRestoreProcess == true) {
ReadBook.restoreLastBookProcess()
} else {
alert(R.string.draw) { alert(R.string.draw) {
setMessage(R.string.restore_last_book_process) setMessage(R.string.restore_last_book_process)
yesButton { yesButton {
confirmRestoreProcess = true
ReadBook.restoreLastBookProcess() //恢复启动全文搜索前的进度 ReadBook.restoreLastBookProcess() //恢复启动全文搜索前的进度
} }
noButton { noButton {
ReadBook.lastBookPress = null ReadBook.lastBookPress = null
confirmRestoreProcess = false
}
onCancelled {
ReadBook.lastBookPress = null
confirmRestoreProcess = false
}
} }
} }
} }

Loading…
Cancel
Save