pull/38/head
kunfei 5 years ago
parent 38e3c77fd9
commit 76ff444675
  1. 24
      app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt

@ -479,21 +479,25 @@ class AnalyzeRule(private var book: BaseBook? = null) {
fun makeUpRule(result: Any?) { fun makeUpRule(result: Any?) {
val infoVal = StringBuilder() val infoVal = StringBuilder()
if (ruleParam.isNotEmpty()) { if (ruleParam.isNotEmpty()) {
var j = ruleParam.size var index = ruleParam.size
while (j-- > 0) { while (index-- > 0) {
val regType = ruleType[j] val regType = ruleType[index]
when { when {
regType > 0 -> { regType > 0 -> {
@Suppress("UNCHECKED_CAST") @Suppress("UNCHECKED_CAST")
val resultList = result as List<String?> val resultList = result as? List<String?>
if (resultList.size > regType) { if (resultList != null) {
resultList[regType]?.let { if (resultList.size > regType) {
infoVal.insert(0, resultList[regType]) resultList[regType]?.let {
infoVal.insert(0, resultList[regType])
}
} }
} else {
infoVal.insert(0, ruleParam[index])
} }
} }
regType == -1 -> { regType == -1 -> {
val jsEval: Any = evalJS(ruleParam[j], result) val jsEval: Any = evalJS(ruleParam[index], result)
if (jsEval is String) { if (jsEval is String) {
infoVal.insert(0, jsEval) infoVal.insert(0, jsEval)
} else if (jsEval is Double && jsEval % 1.0 == 0.0) { } else if (jsEval is Double && jsEval % 1.0 == 0.0) {
@ -503,9 +507,9 @@ class AnalyzeRule(private var book: BaseBook? = null) {
} }
} }
regType == -2 -> { regType == -2 -> {
infoVal.insert(0, get(ruleParam[j])) infoVal.insert(0, get(ruleParam[index]))
} }
else -> infoVal.insert(0, ruleParam[j]) else -> infoVal.insert(0, ruleParam[index])
} }
} }
rule = infoVal.toString() rule = infoVal.toString()

Loading…
Cancel
Save