From c4f3b1a19e578e5dd0ffdadcc1f44a797b10b414 Mon Sep 17 00:00:00 2001 From: gedoor Date: Sun, 26 Dec 2021 22:00:53 +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 --- .../ui/association/FileAssociationViewModel.kt | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/association/FileAssociationViewModel.kt b/app/src/main/java/io/legado/app/ui/association/FileAssociationViewModel.kt index 73880c671..8cab0c3c3 100644 --- a/app/src/main/java/io/legado/app/ui/association/FileAssociationViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/association/FileAssociationViewModel.kt @@ -32,18 +32,12 @@ class FileAssociationViewModel(application: Application) : BaseAssociationViewMo if (it.isJson()) { //暂时根据文件内容判断属于什么 when { - content.contains("bookSourceUrl") -> { + content.contains("bookSourceUrl") -> importBookSourceLive.postValue(it) - return@execute - } - content.contains("sourceUrl") -> { + content.contains("sourceUrl") -> importRssSourceLive.postValue(it) - return@execute - } - content.contains("pattern") -> { + content.contains("pattern") -> importReplaceRuleLive.postValue(it) - return@execute - } content.contains("themeName") -> importTheme(content, finally) content.contains("name") && content.contains("rule") -> @@ -52,9 +46,10 @@ class FileAssociationViewModel(application: Application) : BaseAssociationViewMo importHttpTTS(content, finally) else -> errorLiveData.postValue("格式不对") } + } else { + val book = LocalBook.importFile(uri) + openBookLiveData.postValue(book.bookUrl) } - val book = LocalBook.importFile(uri) - openBookLiveData.postValue(book.bookUrl) } ?: throw NoStackTraceException("文件不存在") } else { onLineImportLive.postValue(uri)