优化
This commit is contained in:
@@ -35,9 +35,10 @@ class FileAssociationViewModel(application: Application) : BaseAssociationViewMo
|
|||||||
} else {
|
} else {
|
||||||
val file = DocumentFile.fromSingleUri(context, uri)
|
val file = DocumentFile.fromSingleUri(context, uri)
|
||||||
content = file?.readText(context) ?: throw NoStackTraceException("文件不存在")
|
content = file?.readText(context) ?: throw NoStackTraceException("文件不存在")
|
||||||
fileName = file!!.name ?: ""
|
fileName = file.name ?: ""
|
||||||
}
|
}
|
||||||
if (content.isJson()) {
|
when {
|
||||||
|
content.isJson() -> {
|
||||||
//暂时根据文件内容判断属于什么
|
//暂时根据文件内容判断属于什么
|
||||||
when {
|
when {
|
||||||
content.contains("bookSourceUrl") ->
|
content.contains("bookSourceUrl") ->
|
||||||
@@ -54,11 +55,14 @@ class FileAssociationViewModel(application: Application) : BaseAssociationViewMo
|
|||||||
importHttpTTS(content, finally)
|
importHttpTTS(content, finally)
|
||||||
else -> errorLiveData.postValue("格式不对")
|
else -> errorLiveData.postValue("格式不对")
|
||||||
}
|
}
|
||||||
} else if (fileName.matches(bookFileRegex)) {
|
}
|
||||||
|
fileName.matches(bookFileRegex) -> {
|
||||||
importBookLiveData.postValue(uri)
|
importBookLiveData.postValue(uri)
|
||||||
} else {
|
}
|
||||||
|
else -> {
|
||||||
throw NoStackTraceException("$fileName 暂未支持的本地书籍格式(TXT/UMD/EPUB)")
|
throw NoStackTraceException("$fileName 暂未支持的本地书籍格式(TXT/UMD/EPUB)")
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
onLineImportLive.postValue(uri)
|
onLineImportLive.postValue(uri)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user