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