mirror of
https://github.com/gedoor/legado.git
synced 2025-08-10 00:52:30 +00:00
优化
This commit is contained in:
@@ -39,6 +39,7 @@ import io.legado.app.utils.mapParallelSafe
|
||||
import io.legado.app.utils.postEvent
|
||||
import io.legado.app.utils.toStringArray
|
||||
import io.legado.app.utils.toastOnUi
|
||||
import kotlinx.coroutines.ensureActive
|
||||
import kotlinx.coroutines.flow.catch
|
||||
import kotlinx.coroutines.flow.collect
|
||||
import kotlinx.coroutines.flow.flow
|
||||
@@ -51,6 +52,7 @@ import java.io.File
|
||||
import java.io.FileInputStream
|
||||
import java.io.FileNotFoundException
|
||||
import java.io.FileOutputStream
|
||||
import kotlin.coroutines.coroutineContext
|
||||
|
||||
/**
|
||||
* 阅读界面数据处理
|
||||
@@ -164,6 +166,7 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) {
|
||||
WebBook.getBookInfoAwait(source, book, canReName = false)
|
||||
return true
|
||||
} catch (e: Throwable) {
|
||||
coroutineContext.ensureActive()
|
||||
ReadBook.upMsg("详情页出错: ${e.localizedMessage}")
|
||||
return false
|
||||
}
|
||||
@@ -219,6 +222,7 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) {
|
||||
ReadBook.onChapterListUpdated(book)
|
||||
return true
|
||||
}.onFailure {
|
||||
coroutineContext.ensureActive()
|
||||
ReadBook.upMsg(context.getString(R.string.error_load_toc))
|
||||
return false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user