|
|
@ -32,18 +32,12 @@ class FileAssociationViewModel(application: Application) : BaseAssociationViewMo |
|
|
|
if (it.isJson()) { |
|
|
|
if (it.isJson()) { |
|
|
|
//暂时根据文件内容判断属于什么 |
|
|
|
//暂时根据文件内容判断属于什么 |
|
|
|
when { |
|
|
|
when { |
|
|
|
content.contains("bookSourceUrl") -> { |
|
|
|
content.contains("bookSourceUrl") -> |
|
|
|
importBookSourceLive.postValue(it) |
|
|
|
importBookSourceLive.postValue(it) |
|
|
|
return@execute |
|
|
|
content.contains("sourceUrl") -> |
|
|
|
} |
|
|
|
|
|
|
|
content.contains("sourceUrl") -> { |
|
|
|
|
|
|
|
importRssSourceLive.postValue(it) |
|
|
|
importRssSourceLive.postValue(it) |
|
|
|
return@execute |
|
|
|
content.contains("pattern") -> |
|
|
|
} |
|
|
|
|
|
|
|
content.contains("pattern") -> { |
|
|
|
|
|
|
|
importReplaceRuleLive.postValue(it) |
|
|
|
importReplaceRuleLive.postValue(it) |
|
|
|
return@execute |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
content.contains("themeName") -> |
|
|
|
content.contains("themeName") -> |
|
|
|
importTheme(content, finally) |
|
|
|
importTheme(content, finally) |
|
|
|
content.contains("name") && content.contains("rule") -> |
|
|
|
content.contains("name") && content.contains("rule") -> |
|
|
@ -52,9 +46,10 @@ class FileAssociationViewModel(application: Application) : BaseAssociationViewMo |
|
|
|
importHttpTTS(content, finally) |
|
|
|
importHttpTTS(content, finally) |
|
|
|
else -> errorLiveData.postValue("格式不对") |
|
|
|
else -> errorLiveData.postValue("格式不对") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
val book = LocalBook.importFile(uri) |
|
|
|
|
|
|
|
openBookLiveData.postValue(book.bookUrl) |
|
|
|
} |
|
|
|
} |
|
|
|
val book = LocalBook.importFile(uri) |
|
|
|
|
|
|
|
openBookLiveData.postValue(book.bookUrl) |
|
|
|
|
|
|
|
} ?: throw NoStackTraceException("文件不存在") |
|
|
|
} ?: throw NoStackTraceException("文件不存在") |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
onLineImportLive.postValue(uri) |
|
|
|
onLineImportLive.postValue(uri) |
|
|
|