优化 #5566
This commit is contained in:
@@ -105,6 +105,16 @@ class ImportRssSourceViewModel(app: Application) : BaseViewModel(app) {
|
|||||||
|
|
||||||
fun importSource(text: String) {
|
fun importSource(text: String) {
|
||||||
execute {
|
execute {
|
||||||
|
importSourceAwait(text)
|
||||||
|
}.onError {
|
||||||
|
errorLiveData.postValue("ImportError:${it.localizedMessage}")
|
||||||
|
AppLog.put("ImportError:${it.localizedMessage}", it)
|
||||||
|
}.onSuccess {
|
||||||
|
comparisonSource()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private suspend fun importSourceAwait(text: String) {
|
||||||
val mText = text.trim()
|
val mText = text.trim()
|
||||||
when {
|
when {
|
||||||
mText.isJsonObject() -> kotlin.runCatching {
|
mText.isJsonObject() -> kotlin.runCatching {
|
||||||
@@ -140,17 +150,11 @@ class ImportRssSourceViewModel(app: Application) : BaseViewModel(app) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mText.isUri() -> {
|
mText.isUri() -> {
|
||||||
importSource(mText.toUri().readText(appCtx))
|
importSourceAwait(mText.toUri().readText(appCtx))
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> throw NoStackTraceException(context.getString(R.string.wrong_format))
|
else -> throw NoStackTraceException(context.getString(R.string.wrong_format))
|
||||||
}
|
}
|
||||||
}.onError {
|
|
||||||
errorLiveData.postValue("ImportError:${it.localizedMessage}")
|
|
||||||
AppLog.put("ImportError:${it.localizedMessage}", it)
|
|
||||||
}.onSuccess {
|
|
||||||
comparisonSource()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun importSourceUrl(url: String) {
|
private suspend fun importSourceUrl(url: String) {
|
||||||
|
|||||||
Reference in New Issue
Block a user