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

@ -90,17 +90,16 @@ object ReadBook : CoroutineScope by MainScope() {
} }
fun setProgress(progress: BookProgress) { fun setProgress(progress: BookProgress) {
if (durChapterIndex != progress.durChapterIndex if (progress.durChapterIndex > chapterSize &&
|| durChapterPos != progress.durChapterPos (durChapterIndex != progress.durChapterIndex
|| durChapterPos != progress.durChapterPos)
) { ) {
if (progress.durChapterIndex > chapterSize) {
durChapterIndex = progress.durChapterIndex durChapterIndex = progress.durChapterIndex
durChapterPos = progress.durChapterPos durChapterPos = progress.durChapterPos
clearTextChapter() clearTextChapter()
loadContent(resetPageOffset = true) loadContent(resetPageOffset = true)
} }
} }
}
fun clearTextChapter() { fun clearTextChapter() {
prevTextChapter = null prevTextChapter = null

@ -220,6 +220,7 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) {
} }
fun openChapter(index: Int, durChapterPos: Int = 0, success: (() -> Unit)? = null) { fun openChapter(index: Int, durChapterPos: Int = 0, success: (() -> Unit)? = null) {
if (index < ReadBook.chapterSize) {
ReadBook.clearTextChapter() ReadBook.clearTextChapter()
ReadBook.callBack?.upContent() ReadBook.callBack?.upContent()
if (index != ReadBook.durChapterIndex) { if (index != ReadBook.durChapterIndex) {
@ -231,6 +232,7 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) {
success?.invoke() success?.invoke()
} }
} }
}
fun removeFromBookshelf(success: (() -> Unit)?) { fun removeFromBookshelf(success: (() -> Unit)?) {
execute { execute {

Loading…
Cancel
Save