Update AnalyzeByJSoup.kt

进一步简化 AnalyzeByJSoup 中的 ElementsSingle,尽量以共享代替传递
pull/1108/head
bushixuanqi 3 years ago committed by GitHub
parent d5aba03fcf
commit 408fb77019
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 22
      app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeByJSoup.kt

@ -42,8 +42,8 @@ class AnalyzeByJSoup(doc: Any) {
* 合并内容列表,得到内容 * 合并内容列表,得到内容
*/ */
internal fun getString(ruleStr: String) = internal fun getString(ruleStr: String) =
if(ruleStr.isEmpty()) null if(ruleStr.isEmpty()) null
else getStringList(ruleStr).takeIf { it.isNotEmpty() }?.joinToString("\n") else getStringList(ruleStr).takeIf { it.isNotEmpty() }?.joinToString("\n")
/** /**
* 获取一个字符串 * 获取一个字符串
@ -75,15 +75,15 @@ class AnalyzeByJSoup(doc: Any) {
for (ruleStrX in ruleStrS) { for (ruleStrX in ruleStrS) {
val temp: List<String>? = val temp: List<String>? =
if (sourceRule.isCss) { if (sourceRule.isCss) {
val lastIndex = ruleStrX.lastIndexOf('@') val lastIndex = ruleStrX.lastIndexOf('@')
getResultLast( getResultLast(
element.select(ruleStrX.substring(0, lastIndex)), element.select(ruleStrX.substring(0, lastIndex)),
ruleStrX.substring(lastIndex + 1) ruleStrX.substring(lastIndex + 1)
) )
} else { } else {
getResultList(ruleStrX) getResultList(ruleStrX)
} }
if (!temp.isNullOrEmpty()) { if (!temp.isNullOrEmpty()) {

Loading…
Cancel
Save