This commit is contained in:
gedoor
2022-01-10 20:54:13 +08:00
parent 95e0d64061
commit f94ce733b2
2 changed files with 18 additions and 17 deletions
@@ -90,17 +90,16 @@ object ReadBook : CoroutineScope by MainScope() {
}
fun setProgress(progress: BookProgress) {
if (durChapterIndex != progress.durChapterIndex
|| durChapterPos != progress.durChapterPos
if (progress.durChapterIndex > chapterSize &&
(durChapterIndex != progress.durChapterIndex
|| durChapterPos != progress.durChapterPos)
) {
if (progress.durChapterIndex > chapterSize) {
durChapterIndex = progress.durChapterIndex
durChapterPos = progress.durChapterPos
clearTextChapter()
loadContent(resetPageOffset = true)
}
}
}
fun clearTextChapter() {
prevTextChapter = null
@@ -220,6 +220,7 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) {
}
fun openChapter(index: Int, durChapterPos: Int = 0, success: (() -> Unit)? = null) {
if (index < ReadBook.chapterSize) {
ReadBook.clearTextChapter()
ReadBook.callBack?.upContent()
if (index != ReadBook.durChapterIndex) {
@@ -231,6 +232,7 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) {
success?.invoke()
}
}
}
fun removeFromBookshelf(success: (() -> Unit)?) {
execute {