From 05472a9c71f828e582a59e5653d9e507d7fb7e9e Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 6 Nov 2022 00:21:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/ui/association/AddToBookshelfDialog.kt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/src/main/java/io/legado/app/ui/association/AddToBookshelfDialog.kt b/app/src/main/java/io/legado/app/ui/association/AddToBookshelfDialog.kt index b1701e4e8..6fbf12678 100644 --- a/app/src/main/java/io/legado/app/ui/association/AddToBookshelfDialog.kt +++ b/app/src/main/java/io/legado/app/ui/association/AddToBookshelfDialog.kt @@ -10,6 +10,7 @@ import androidx.lifecycle.MutableLiveData import io.legado.app.R import io.legado.app.base.BaseDialogFragment import io.legado.app.base.BaseViewModel +import io.legado.app.constant.AppLog import io.legado.app.data.appDb import io.legado.app.data.entities.Book import io.legado.app.databinding.DialogAddToBookshelfBinding @@ -54,6 +55,9 @@ class AddToBookshelfDialog() : BaseDialogFragment(R.layout.dialog_add_to_bookshe viewModel.loadStateLiveData.observe(this) { //todo } + viewModel.loadErrorLiveData.observe(this) { + //todo + } viewModel.load(bookUrl) { //todo } @@ -62,6 +66,7 @@ class AddToBookshelfDialog() : BaseDialogFragment(R.layout.dialog_add_to_bookshe class ViewModel(application: Application) : BaseViewModel(application) { val loadStateLiveData = MutableLiveData() + val loadErrorLiveData = MutableLiveData() fun load(bookUrl: String, success: (book: Book) -> Unit) { execute { @@ -90,6 +95,9 @@ class AddToBookshelfDialog() : BaseDialogFragment(R.layout.dialog_add_to_bookshe book.order = appDb.bookDao.minOrder - 1 return@execute book } ?: throw NoStackTraceException("未找到匹配书源") + }.onError { + AppLog.put("添加书籍 ${bookUrl} 出错", it) + loadErrorLiveData.postValue(it.localizedMessage) }.onSuccess { success.invoke(it) }.onStart {