From 87693d4e3b96da3b5f37b2d114c968e44df358d4 Mon Sep 17 00:00:00 2001 From: gedoor Date: Tue, 8 Dec 2020 16:51:16 +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/ImportBookSourceViewModel.kt | 16 ++++++++-------- .../ui/association/ImportRssSourceViewModel.kt | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/association/ImportBookSourceViewModel.kt b/app/src/main/java/io/legado/app/ui/association/ImportBookSourceViewModel.kt index 50fa74db2..664513bc0 100644 --- a/app/src/main/java/io/legado/app/ui/association/ImportBookSourceViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/association/ImportBookSourceViewModel.kt @@ -81,23 +81,23 @@ class ImportBookSourceViewModel(app: Application) : BaseViewModel(app) { fun importSource(text: String) { execute { - val text1 = text.trim() + val mText = text.trim() when { - text1.isJsonObject() -> { - val json = JsonPath.parse(text1) + mText.isJsonObject() -> { + val json = JsonPath.parse(mText) val urls = json.read>("$.sourceUrls") if (!urls.isNullOrEmpty()) { urls.forEach { importSourceUrl(it) } } else { - OldRule.jsonToBookSource(text1)?.let { + OldRule.jsonToBookSource(mText)?.let { allSources.add(it) } } } - text1.isJsonArray() -> { - val items: List> = Restore.jsonPath.parse(text1).read("$") + mText.isJsonArray() -> { + val items: List> = Restore.jsonPath.parse(mText).read("$") for (item in items) { val jsonItem = Restore.jsonPath.parse(item) OldRule.jsonToBookSource(jsonItem.jsonString())?.let { @@ -105,8 +105,8 @@ class ImportBookSourceViewModel(app: Application) : BaseViewModel(app) { } } } - text1.isAbsUrl() -> { - importSourceUrl(text1) + mText.isAbsUrl() -> { + importSourceUrl(mText) } else -> throw Exception(context.getString(R.string.wrong_format)) } diff --git a/app/src/main/java/io/legado/app/ui/association/ImportRssSourceViewModel.kt b/app/src/main/java/io/legado/app/ui/association/ImportRssSourceViewModel.kt index 47616cef9..751390a93 100644 --- a/app/src/main/java/io/legado/app/ui/association/ImportRssSourceViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/association/ImportRssSourceViewModel.kt @@ -77,23 +77,23 @@ class ImportRssSourceViewModel(app: Application) : BaseViewModel(app) { fun importSource(text: String) { execute { - val text1 = text.trim() + val mText = text.trim() when { - text1.isJsonObject() -> { - val json = JsonPath.parse(text1) + mText.isJsonObject() -> { + val json = JsonPath.parse(mText) val urls = json.read>("$.sourceUrls") if (!urls.isNullOrEmpty()) { urls.forEach { importSourceUrl(it) } } else { - GSON.fromJsonArray(text1)?.let { + GSON.fromJsonArray(mText)?.let { allSources.addAll(it) } } } - text1.isJsonArray() -> { - val items: List> = Restore.jsonPath.parse(text1).read("$") + mText.isJsonArray() -> { + val items: List> = Restore.jsonPath.parse(mText).read("$") for (item in items) { val jsonItem = Restore.jsonPath.parse(item) GSON.fromJsonObject(jsonItem.jsonString())?.let { @@ -101,8 +101,8 @@ class ImportRssSourceViewModel(app: Application) : BaseViewModel(app) { } } } - text1.isAbsUrl() -> { - importSourceUrl(text1) + mText.isAbsUrl() -> { + importSourceUrl(mText) } else -> throw Exception(context.getString(R.string.wrong_format)) }