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