mirror of
https://github.com/gedoor/legado.git
synced 2024-07-06 23:47:49 +08:00
优化
This commit is contained in:
parent
64cc37bdb5
commit
f632d3f936
@ -288,21 +288,26 @@ object ReadBook : CoroutineScope by MainScope() {
|
||||
}
|
||||
|
||||
fun setPageIndex(index: Int) {
|
||||
val textChapter = curTextChapter
|
||||
if (textChapter != null) {
|
||||
val pageIndex = durPageIndex
|
||||
if (index > pageIndex) {
|
||||
textChapter.getPage(index - 2)?.recycleRecorders()
|
||||
}
|
||||
if (index < pageIndex) {
|
||||
textChapter.getPage(index + 3)?.recycleRecorders()
|
||||
}
|
||||
}
|
||||
recycleRecorders(durPageIndex, index)
|
||||
durChapterPos = curTextChapter?.getReadLength(index) ?: index
|
||||
saveRead(true)
|
||||
curPageChanged(true)
|
||||
}
|
||||
|
||||
fun recycleRecorders(beforeIndex: Int, afterIndex: Int) {
|
||||
executor.execute {
|
||||
val textChapter = curTextChapter
|
||||
if (textChapter != null) {
|
||||
if (afterIndex > beforeIndex) {
|
||||
textChapter.getPage(afterIndex - 2)?.recycleRecorders()
|
||||
}
|
||||
if (afterIndex < beforeIndex) {
|
||||
textChapter.getPage(afterIndex + 3)?.recycleRecorders()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun openChapter(index: Int, durChapterPos: Int = 0, success: (() -> Unit)? = null) {
|
||||
if (index < chapterSize) {
|
||||
clearTextChapter()
|
||||
|
Loading…
Reference in New Issue
Block a user