mirror of
https://github.com/gedoor/legado.git
synced 2024-09-01 09:34:25 +08:00
优化
This commit is contained in:
parent
95e0d64061
commit
f94ce733b2
@ -90,15 +90,14 @@ 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)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,15 +220,17 @@ 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) {
|
||||||
ReadBook.clearTextChapter()
|
if (index < ReadBook.chapterSize) {
|
||||||
ReadBook.callBack?.upContent()
|
ReadBook.clearTextChapter()
|
||||||
if (index != ReadBook.durChapterIndex) {
|
ReadBook.callBack?.upContent()
|
||||||
ReadBook.durChapterIndex = index
|
if (index != ReadBook.durChapterIndex) {
|
||||||
ReadBook.durChapterPos = durChapterPos
|
ReadBook.durChapterIndex = index
|
||||||
}
|
ReadBook.durChapterPos = durChapterPos
|
||||||
ReadBook.saveRead()
|
}
|
||||||
ReadBook.loadContent(resetPageOffset = true) {
|
ReadBook.saveRead()
|
||||||
success?.invoke()
|
ReadBook.loadContent(resetPageOffset = true) {
|
||||||
|
success?.invoke()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user