修复详情页初始化:规则bug

pull/1295/head
gedoor 3 years ago
parent 80dbdc9d07
commit 315c275ab1
  1. 8
      app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt

@ -128,7 +128,7 @@ class AnalyzeRule(
@JvmOverloads @JvmOverloads
fun getStringList(rule: String?, isUrl: Boolean = false): List<String>? { fun getStringList(rule: String?, isUrl: Boolean = false): List<String>? {
if (rule.isNullOrEmpty()) return null if (rule.isNullOrEmpty()) return null
val ruleList = splitSourceRule(rule, true) val ruleList = splitSourceRule(rule, false)
return getStringList(ruleList, isUrl) return getStringList(ruleList, isUrl)
} }
@ -256,7 +256,7 @@ class AnalyzeRule(
fun getElement(ruleStr: String): Any? { fun getElement(ruleStr: String): Any? {
if (TextUtils.isEmpty(ruleStr)) return null if (TextUtils.isEmpty(ruleStr)) return null
var result: Any? = null var result: Any? = null
val ruleList = splitSourceRule(ruleStr) val ruleList = splitSourceRule(ruleStr, true)
content?.let { o -> content?.let { o ->
if (ruleList.isNotEmpty()) result = o if (ruleList.isNotEmpty()) result = o
for (sourceRule in ruleList) { for (sourceRule in ruleList) {
@ -370,13 +370,13 @@ class AnalyzeRule(
/** /**
* 分解规则生成规则列表 * 分解规则生成规则列表
*/ */
fun splitSourceRule(ruleStr: String?, isList: Boolean = false): List<SourceRule> { fun splitSourceRule(ruleStr: String?, allInOne: Boolean = false): List<SourceRule> {
if (ruleStr.isNullOrEmpty()) return ArrayList<SourceRule>() if (ruleStr.isNullOrEmpty()) return ArrayList<SourceRule>()
val ruleList = ArrayList<SourceRule>() val ruleList = ArrayList<SourceRule>()
var mMode: Mode = Mode.Default var mMode: Mode = Mode.Default
var start = 0 var start = 0
//仅首字符为:时为AllInOne,其实:与伪类选择器冲突,建议改成?更合理 //仅首字符为:时为AllInOne,其实:与伪类选择器冲突,建议改成?更合理
if (isList && ruleStr.startsWith(":")) { if (allInOne && ruleStr.startsWith(":")) {
mMode = Mode.Regex mMode = Mode.Regex
isRegex = true isRegex = true
start = 1 start = 1

Loading…
Cancel
Save