|
@@ -39,6 +39,7 @@ import io.legado.app.utils.mapParallelSafe
|
|
|
import io.legado.app.utils.postEvent
|
|
import io.legado.app.utils.postEvent
|
|
|
import io.legado.app.utils.toStringArray
|
|
import io.legado.app.utils.toStringArray
|
|
|
import io.legado.app.utils.toastOnUi
|
|
import io.legado.app.utils.toastOnUi
|
|
|
|
|
+import kotlinx.coroutines.ensureActive
|
|
|
import kotlinx.coroutines.flow.catch
|
|
import kotlinx.coroutines.flow.catch
|
|
|
import kotlinx.coroutines.flow.collect
|
|
import kotlinx.coroutines.flow.collect
|
|
|
import kotlinx.coroutines.flow.flow
|
|
import kotlinx.coroutines.flow.flow
|
|
@@ -51,6 +52,7 @@ import java.io.File
|
|
|
import java.io.FileInputStream
|
|
import java.io.FileInputStream
|
|
|
import java.io.FileNotFoundException
|
|
import java.io.FileNotFoundException
|
|
|
import java.io.FileOutputStream
|
|
import java.io.FileOutputStream
|
|
|
|
|
+import kotlin.coroutines.coroutineContext
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 阅读界面数据处理
|
|
* 阅读界面数据处理
|
|
@@ -164,6 +166,7 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) {
|
|
|
WebBook.getBookInfoAwait(source, book, canReName = false)
|
|
WebBook.getBookInfoAwait(source, book, canReName = false)
|
|
|
return true
|
|
return true
|
|
|
} catch (e: Throwable) {
|
|
} catch (e: Throwable) {
|
|
|
|
|
+ coroutineContext.ensureActive()
|
|
|
ReadBook.upMsg("详情页出错: ${e.localizedMessage}")
|
|
ReadBook.upMsg("详情页出错: ${e.localizedMessage}")
|
|
|
return false
|
|
return false
|
|
|
}
|
|
}
|
|
@@ -219,6 +222,7 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) {
|
|
|
ReadBook.onChapterListUpdated(book)
|
|
ReadBook.onChapterListUpdated(book)
|
|
|
return true
|
|
return true
|
|
|
}.onFailure {
|
|
}.onFailure {
|
|
|
|
|
+ coroutineContext.ensureActive()
|
|
|
ReadBook.upMsg(context.getString(R.string.error_load_toc))
|
|
ReadBook.upMsg(context.getString(R.string.error_load_toc))
|
|
|
return false
|
|
return false
|
|
|
}
|
|
}
|