This commit is contained in:
Horis
2024-02-22 13:05:38 +08:00
parent 557c32c834
commit aabeef4e27
@@ -13,6 +13,7 @@ import io.legado.app.help.book.BookHelp
import io.legado.app.help.config.AppConfig import io.legado.app.help.config.AppConfig
import io.legado.app.help.config.ReadBookConfig import io.legado.app.help.config.ReadBookConfig
import io.legado.app.help.coroutine.Coroutine import io.legado.app.help.coroutine.Coroutine
import io.legado.app.help.globalExecutor
import io.legado.app.model.ImageProvider import io.legado.app.model.ImageProvider
import io.legado.app.model.ReadBook import io.legado.app.model.ReadBook
import io.legado.app.ui.book.read.page.entities.TextChapter import io.legado.app.ui.book.read.page.entities.TextChapter
@@ -68,7 +69,7 @@ class TextChapterLayout(
private val stringBuilder = StringBuilder() private val stringBuilder = StringBuilder()
private var isCompleted = false private var isCompleted = false
private val job: Coroutine<*> private var job: Coroutine<*>? = null
private val bookChapter inline get() = textChapter.chapter private val bookChapter inline get() = textChapter.chapter
private val displayTitle inline get() = textChapter.title private val displayTitle inline get() = textChapter.title
private val chaptersSize inline get() = textChapter.chaptersSize private val chaptersSize inline get() = textChapter.chaptersSize
@@ -76,6 +77,7 @@ class TextChapterLayout(
var exception: Throwable? = null var exception: Throwable? = null
init { init {
globalExecutor.submit {
job = Coroutine.async(scope) { job = Coroutine.async(scope) {
launch { launch {
val bookSource = book.getBookSource() ?: return@launch val bookSource = book.getBookSource() ?: return@launch
@@ -89,6 +91,7 @@ class TextChapterLayout(
isCompleted = true isCompleted = true
} }
} }
}
fun setProgressListener(l: LayoutProgressListener?) { fun setProgressListener(l: LayoutProgressListener?) {
try { try {
@@ -106,7 +109,7 @@ class TextChapterLayout(
} }
fun cancel() { fun cancel() {
job.cancel() job?.cancel()
} }
private fun onPageCompleted() { private fun onPageCompleted() {