优化
This commit is contained in:
@@ -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 {
|
||||||
|
|||||||
Reference in New Issue
Block a user