优化
This commit is contained in:
@@ -15,7 +15,6 @@ class FileAssociationViewModel(application: Application) : BaseAssociationViewMo
|
|||||||
val openBookLiveData = MutableLiveData<String>()
|
val openBookLiveData = MutableLiveData<String>()
|
||||||
val notSupportedLiveData = MutableLiveData<Pair<Uri, String>>()
|
val notSupportedLiveData = MutableLiveData<Pair<Uri, String>>()
|
||||||
|
|
||||||
@Suppress("BlockingMethodInNonBlockingContext")
|
|
||||||
fun dispatchIndent(uri: Uri) {
|
fun dispatchIndent(uri: Uri) {
|
||||||
execute {
|
execute {
|
||||||
lateinit var fileName: String
|
lateinit var fileName: String
|
||||||
@@ -42,7 +41,7 @@ class FileAssociationViewModel(application: Application) : BaseAssociationViewMo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun dispatch(fileDoc: FileDoc) {
|
private fun dispatch(fileDoc: FileDoc) {
|
||||||
kotlin.runCatching {
|
kotlin.runCatching {
|
||||||
if (fileDoc.openInputStream().getOrNull().isJson()) {
|
if (fileDoc.openInputStream().getOrNull().isJson()) {
|
||||||
importJson(fileDoc.uri)
|
importJson(fileDoc.uri)
|
||||||
|
|||||||
@@ -26,15 +26,13 @@ class TocViewModel(application: Application) : BaseViewModel(application) {
|
|||||||
|
|
||||||
fun upBookTocRule(book: Book, finally: () -> Unit) {
|
fun upBookTocRule(book: Book, finally: () -> Unit) {
|
||||||
execute {
|
execute {
|
||||||
execute {
|
appDb.bookDao.update(book)
|
||||||
|
LocalBook.getChapterList(book).let {
|
||||||
|
book.latestChapterTime = System.currentTimeMillis()
|
||||||
|
appDb.bookChapterDao.delByBook(book.bookUrl)
|
||||||
|
appDb.bookChapterDao.insert(*it.toTypedArray())
|
||||||
appDb.bookDao.update(book)
|
appDb.bookDao.update(book)
|
||||||
LocalBook.getChapterList(book).let {
|
bookData.postValue(book)
|
||||||
book.latestChapterTime = System.currentTimeMillis()
|
|
||||||
appDb.bookChapterDao.delByBook(book.bookUrl)
|
|
||||||
appDb.bookChapterDao.insert(*it.toTypedArray())
|
|
||||||
appDb.bookDao.update(book)
|
|
||||||
bookData.postValue(book)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}.onFinally {
|
}.onFinally {
|
||||||
finally.invoke()
|
finally.invoke()
|
||||||
|
|||||||
Reference in New Issue
Block a user