From 55bd31d803dbb138bf3fe882a4fc131e67b0c7f8 Mon Sep 17 00:00:00 2001 From: gedoor Date: Sat, 7 Nov 2020 19:41:37 +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 --- app/src/main/assets/help/bookSource.md | 0 app/src/main/assets/help/rssSource.md | 0 .../app/model/analyzeRule/AnalyzeRule.kt | 48 ++++++++----------- 3 files changed, 20 insertions(+), 28 deletions(-) create mode 100644 app/src/main/assets/help/bookSource.md create mode 100644 app/src/main/assets/help/rssSource.md diff --git a/app/src/main/assets/help/bookSource.md b/app/src/main/assets/help/bookSource.md new file mode 100644 index 000000000..e69de29bb diff --git a/app/src/main/assets/help/rssSource.md b/app/src/main/assets/help/rssSource.md new file mode 100644 index 000000000..e69de29bb diff --git a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt index 5296196ce..bd7b09236 100644 --- a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt +++ b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt @@ -66,16 +66,13 @@ class AnalyzeRule(var book: BaseBook? = null) : JsExtensions { private fun getAnalyzeByXPath(o: Any): AnalyzeByXPath { return if (o != content) { AnalyzeByXPath().parse(o) - } else getAnalyzeByXPath() - } - - private fun getAnalyzeByXPath(): AnalyzeByXPath { - if (analyzeByXPath == null || objectChangedXP) { - analyzeByXPath = AnalyzeByXPath() - analyzeByXPath?.parse(content!!) - objectChangedXP = false + } else { + if (analyzeByXPath == null || objectChangedXP) { + analyzeByXPath = AnalyzeByXPath().parse(content!!) + objectChangedXP = false + } + analyzeByXPath!! } - return analyzeByXPath as AnalyzeByXPath } /** @@ -84,16 +81,13 @@ class AnalyzeRule(var book: BaseBook? = null) : JsExtensions { private fun getAnalyzeByJSoup(o: Any): AnalyzeByJSoup { return if (o != content) { AnalyzeByJSoup().parse(o) - } else getAnalyzeByJSoup() - } - - private fun getAnalyzeByJSoup(): AnalyzeByJSoup { - if (analyzeByJSoup == null || objectChangedJS) { - analyzeByJSoup = AnalyzeByJSoup() - analyzeByJSoup?.parse(content!!) - objectChangedJS = false + } else { + if (analyzeByJSoup == null || objectChangedJS) { + analyzeByJSoup = AnalyzeByJSoup().parse(content!!) + objectChangedJS = false + } + analyzeByJSoup!! } - return analyzeByJSoup as AnalyzeByJSoup } /** @@ -102,16 +96,13 @@ class AnalyzeRule(var book: BaseBook? = null) : JsExtensions { private fun getAnalyzeByJSonPath(o: Any): AnalyzeByJSonPath { return if (o != content) { AnalyzeByJSonPath().parse(o) - } else getAnalyzeByJSonPath() - } - - private fun getAnalyzeByJSonPath(): AnalyzeByJSonPath { - if (analyzeByJSonPath == null || objectChangedJP) { - analyzeByJSonPath = AnalyzeByJSonPath() - analyzeByJSonPath?.parse(content!!) - objectChangedJP = false + } else { + if (analyzeByJSonPath == null || objectChangedJP) { + analyzeByJSonPath = AnalyzeByJSonPath().parse(content!!) + objectChangedJP = false + } + analyzeByJSonPath!! } - return analyzeByJSonPath as AnalyzeByJSonPath } /** @@ -124,6 +115,7 @@ class AnalyzeRule(var book: BaseBook? = null) : JsExtensions { return getStringList(ruleList, isUrl) } + @JvmOverloads fun getStringList(ruleList: List, isUrl: Boolean = false): List? { var result: Any? = null val content = this.content @@ -181,6 +173,7 @@ class AnalyzeRule(var book: BaseBook? = null) : JsExtensions { /** * 获取文本 */ + @JvmOverloads fun getString(ruleStr: String?, isUrl: Boolean = false): String { if (TextUtils.isEmpty(ruleStr)) return "" val ruleList = splitSourceRule(ruleStr) @@ -302,7 +295,6 @@ class AnalyzeRule(var book: BaseBook? = null) : JsExtensions { return ArrayList() } - /** * 保存变量 */