From 9fa16062df09386d61f4f01538334aaf1a95659c Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 18 Aug 2019 19:49:24 +0800 Subject: [PATCH] up --- .../app/model/analyzeRule/AnalyzeRule.kt | 41 ++++++++++--------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt index 2689f7366..38bda7e0d 100644 --- a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt +++ b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt @@ -472,31 +472,32 @@ class AnalyzeRule(private var book: BaseBook? = null) { fun makeUpRule(result: Any?) { val infoVal = StringBuilder() - var j = ruleParam.size - while (j-- > 0) { - val regType = ruleType[j] - if (regType > 0) { - @Suppress("UNCHECKED_CAST") - val resultList = result as List - if (resultList.size > regType) { - infoVal.insert(0, resultList[regType]) - } - } else if (regType < 0) { - val jsEval: Any = evalJS(ruleParam[j], result) - if (jsEval is String) { - infoVal.insert(0, jsEval) - } else if (jsEval is Double && jsEval % 1.0 == 0.0) { - infoVal.insert(0, String.format("%.0f", jsEval)) + if (ruleParam.isNotEmpty()) { + var j = ruleParam.size + while (j-- > 0) { + val regType = ruleType[j] + if (regType > 0) { + @Suppress("UNCHECKED_CAST") + val resultList = result as List + if (resultList.size > regType) { + infoVal.insert(0, resultList[regType]) + } + } else if (regType < 0) { + val jsEval: Any = evalJS(ruleParam[j], result) + if (jsEval is String) { + infoVal.insert(0, jsEval) + } else if (jsEval is Double && jsEval % 1.0 == 0.0) { + infoVal.insert(0, String.format("%.0f", jsEval)) + } else { + infoVal.insert(0, jsEval.toString()) + } } else { - infoVal.insert(0, jsEval.toString()) + infoVal.insert(0, ruleParam[j]) } - } else { - infoVal.insert(0, ruleParam[j]) } + rule = infoVal.toString() } - rule = infoVal.toString() } - } enum class Mode {