Skip to content

Commit

Permalink
优化
Browse files Browse the repository at this point in the history
  • Loading branch information
821938089 committed Nov 5, 2023
1 parent 912c56c commit 3424ed1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ class ReadBookActivity : BaseReadBookActivity(),
private var pageChanged = false
private var reloadContent = false
private val autoPageRenderer by lazy { SyncedRenderer { doAutoPage(it) } }
private var autoPageScrollOffset = 0.0

//恢复跳转前进度对话框的交互结果
private var confirmRestoreProcess: Boolean? = null
Expand Down Expand Up @@ -969,6 +970,7 @@ class ReadBookActivity : BaseReadBookActivity(),
}

private fun autoPagePlus() {
autoPageScrollOffset = 0.0
autoPageRenderer.start()
}

Expand All @@ -981,7 +983,12 @@ class ReadBookActivity : BaseReadBookActivity(),
}
val readTime = ReadBookConfig.autoReadSpeed * 1000.0
val height = binding.readView.height
val scrollOffset = (height / readTime * frameTime).toInt().coerceAtLeast(1)
autoPageScrollOffset += height / readTime * frameTime
if (autoPageScrollOffset < 1) {
return
}
val scrollOffset = autoPageScrollOffset.toInt()
autoPageScrollOffset -= scrollOffset
if (binding.readView.isScroll) {
binding.readView.curPage.scroll(-scrollOffset)
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ class BackupConfigFragment : PreferenceFragment(),
}.onError {
AppLog.put("备份出错\n${it.localizedMessage}", it)
appCtx.toastOnUi(appCtx.getString(R.string.backup_fail, it.localizedMessage))
}.onFinally(Main) {
}.onFinally {
waitDialog.dismiss()
}
}
Expand All @@ -342,6 +342,9 @@ class BackupConfigFragment : PreferenceFragment(),
showRestoreDialog(requireContext())
}.onError {
AppLog.put("恢复备份出错WebDavError\n${it.localizedMessage}", it)
if (context == null) {
return@onError
}
alert {
setTitle(R.string.restore)
setMessage("WebDavError\n${it.localizedMessage}\n将从本地备份恢复。")
Expand All @@ -350,7 +353,7 @@ class BackupConfigFragment : PreferenceFragment(),
}
cancelButton()
}
}.onFinally(Main) {
}.onFinally {
waitDialog.dismiss()
}
}
Expand Down Expand Up @@ -387,7 +390,7 @@ class BackupConfigFragment : PreferenceFragment(),
}.onError {
AppLog.put("WebDav恢复出错\n${it.localizedMessage}", it)
appCtx.toastOnUi("WebDav恢复出错\n${it.localizedMessage}")
}.onFinally(Main) {
}.onFinally {
waitDialog.dismiss()
}
waitDialog.setOnCancelListener {
Expand Down

0 comments on commit 3424ed1

Please sign in to comment.