From 0786240f12573d606d77691ad417eda5e893e41c Mon Sep 17 00:00:00 2001 From: gedoor Date: Fri, 16 Oct 2020 13:40:14 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=A7=84=E5=88=99=E8=A7=A3?= =?UTF-8?q?=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/model/analyzeRule/AnalyzeByJSoup.kt | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 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 bf00f0d43..21cb1e288 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 @@ -18,6 +18,10 @@ import java.util.* */ @Keep class AnalyzeByJSoup { + companion object { + val validKeys = arrayOf("class", "id", "tag", "text", "children") + } + private var element: Element? = null fun parse(doc: Any): AnalyzeByJSoup { @@ -232,18 +236,18 @@ class AnalyzeByJSoup { elements.addAll(es) } } else { - val rulePcx = rule.splitNotBlank("!") - val rulePc = - rulePcx[0].trim { it <= ' ' }.splitNotBlank(">") - val rules = - rulePc[0].trim { it <= ' ' }.splitNotBlank(".") + val rulePcx = rule.split("!") + val rulePc = rulePcx[0].trim { it <= ' ' }.split(">") + val rules = rulePc[0].trim { it <= ' ' }.split(".") var filterRules: Array? = null var needFilterElements = rulePc.size > 1 && !isEmpty(rulePc[1].trim { it <= ' ' }) if (needFilterElements) { - filterRules = rulePc[1].trim { it <= ' ' }.splitNotBlank(".") + filterRules = rulePc[1].trim { it <= ' ' }.split(".").toTypedArray() filterRules[0] = filterRules[0].trim { it <= ' ' } - val validKeys = listOf("class", "id", "tag", "text") - if (filterRules.size < 2 || !validKeys.contains(filterRules[0]) || isEmpty(filterRules[1].trim { it <= ' ' })) { + if (filterRules.size < 2 + || !validKeys.contains(filterRules[0]) + || filterRules[1].trim { it <= ' ' }.isEmpty() + ) { needFilterElements = false } filterRules[1] = filterRules[1].trim { it <= ' ' }