From 190eb6eff59bc58661b9fad3f5e34eeb23c14fd4 Mon Sep 17 00:00:00 2001 From: kunfei Date: Tue, 6 Aug 2019 14:15:04 +0800 Subject: [PATCH 1/2] up --- .../io/legado/app/model/analyzeRule/AnalyzeByJSonPath.kt | 8 ++++---- .../io/legado/app/model/analyzeRule/AnalyzeByJSoup.kt | 4 ++-- .../io/legado/app/model/analyzeRule/AnalyzeByXPath.kt | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeByJSonPath.kt b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeByJSonPath.kt index 298c1d2fa..60a3510c2 100644 --- a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeByJSonPath.kt +++ b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeByJSonPath.kt @@ -62,17 +62,17 @@ class AnalyzeByJSonPath { return result } } else { - val sb = StringBuilder() + val textList = arrayListOf() for (rl in rules) { val temp = getString(rl) - if (!TextUtils.isEmpty(temp)) { - sb.append(temp) + if (!temp.isNullOrEmpty()) { + textList.add(temp) if (elementsType == "|") { break } } } - return sb.toString() + return TextUtils.join(",", textList) } } diff --git a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeByJSoup.kt b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeByJSoup.kt index 879d18b05..7be879bbe 100644 --- a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeByJSoup.kt +++ b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeByJSoup.kt @@ -75,7 +75,7 @@ class AnalyzeByJSoup { //拆分规则 val sourceRule = SourceRule(ruleStr) if (isEmpty(sourceRule.elementsRule)) { - textS.add(element!!.data()) + textS.add(element?.data() ?: "") } else { val elementsType: String val ruleStrS: Array @@ -105,7 +105,7 @@ class AnalyzeByJSoup { } else { getResultList(ruleStrX) } - if (temp != null && temp.isNotEmpty()) { + if (!temp.isNullOrEmpty()) { results.add(temp) if (results.isNotEmpty() && elementsType == "|") { break diff --git a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeByXPath.kt b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeByXPath.kt index 23030393c..0989f88d5 100644 --- a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeByXPath.kt +++ b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeByXPath.kt @@ -154,17 +154,17 @@ class AnalyzeByXPath { } return null } else { - val sb = StringBuilder() + val textList = arrayListOf() for (rl in rules) { val temp = getString(rl) - if (!TextUtils.isEmpty(temp)) { - sb.append(temp) + if (!temp.isNullOrEmpty()) { + textList.add(temp) if (elementsType == "|") { break } } } - return sb.toString() + return TextUtils.join(",", textList) } } } From 5d0462c2f7b8cf25d509f10d769b77e77b5e2275 Mon Sep 17 00:00:00 2001 From: kunfei Date: Tue, 6 Aug 2019 14:39:55 +0800 Subject: [PATCH 2/2] up --- .../io/legado/app/model/analyzeRule/AnalyzeByJSoup.kt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeByJSoup.kt b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeByJSoup.kt index 7be879bbe..32e7d2a16 100644 --- a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeByJSoup.kt +++ b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeByJSoup.kt @@ -51,7 +51,7 @@ class AnalyzeByJSoup { val textS = getStringList(ruleStr) return if (textS.isEmpty()) { null - } else join("\n", textS).trim { it <= ' ' } + } else join(",", textS).trim { it <= ' ' } } /** @@ -360,13 +360,15 @@ class AnalyzeByJSoup { textS.add(text) } "textNodes" -> for (element in elements) { + val tn = arrayListOf() val contentEs = element.textNodes() - for (i in contentEs.indices) { - val temp = contentEs[i].text().trim { it <= ' ' } + for (item in contentEs) { + val temp = item.text().trim { it <= ' ' } if (!isEmpty(temp)) { - textS.add(temp) + tn.add(temp) } } + textS.add(join("\n", tn)) } "ownText", "html" -> { elements.select("script").remove()