pull/1514/head 3.22.011020
gedoor 3 years ago
parent 95e0d64061
commit f94ce733b2
  1. 15
      app/src/main/java/io/legado/app/model/ReadBook.kt
  2. 20
      app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt

@ -90,15 +90,14 @@ 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)
}
durChapterIndex = progress.durChapterIndex
durChapterPos = progress.durChapterPos
clearTextChapter()
loadContent(resetPageOffset = true)
}
}

@ -220,15 +220,17 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) {
}
fun openChapter(index: Int, durChapterPos: Int = 0, success: (() -> Unit)? = null) {
ReadBook.clearTextChapter()
ReadBook.callBack?.upContent()
if (index != ReadBook.durChapterIndex) {
ReadBook.durChapterIndex = index
ReadBook.durChapterPos = durChapterPos
}
ReadBook.saveRead()
ReadBook.loadContent(resetPageOffset = true) {
success?.invoke()
if (index < ReadBook.chapterSize) {
ReadBook.clearTextChapter()
ReadBook.callBack?.upContent()
if (index != ReadBook.durChapterIndex) {
ReadBook.durChapterIndex = index
ReadBook.durChapterPos = durChapterPos
}
ReadBook.saveRead()
ReadBook.loadContent(resetPageOffset = true) {
success?.invoke()
}
}
}

Loading…
Cancel
Save