This commit is contained in:
gedoor 2021-12-26 22:00:53 +08:00
parent a5fbce7963
commit c4f3b1a19e

View File

@ -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)