From 28623487e536c03eff6dd4178af3a7baa0973dbd Mon Sep 17 00:00:00 2001 From: gedoor Date: Fri, 1 Jan 2021 22:11:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt | 4 +++- app/src/main/java/io/legado/app/utils/StringUtils.kt | 5 ++--- 2 files changed, 5 insertions(+), 4 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 a1d75941c..5445884bf 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 @@ -231,7 +231,9 @@ class AnalyzeRule(val ruleData: RuleDataInterface) : JsExtensions { if (result == null) result = "" val str = kotlin.runCatching { Entities.unescape(result.toString()) - }.getOrDefault(result.toString()) + }.getOrElse { + result.toString() + } if (isUrl) { return if (str.isBlank()) { baseUrl ?: "" diff --git a/app/src/main/java/io/legado/app/utils/StringUtils.kt b/app/src/main/java/io/legado/app/utils/StringUtils.kt index 89d561cbf..b810ffa0d 100644 --- a/app/src/main/java/io/legado/app/utils/StringUtils.kt +++ b/app/src/main/java/io/legado/app/utils/StringUtils.kt @@ -214,12 +214,11 @@ object StringUtils { fun stringToInt(str: String?): Int { if (str != null) { val num = fullToHalf(str).replace("\\s+".toRegex(), "") - return try { + return kotlin.runCatching { Integer.parseInt(num) - } catch (e: Exception) { + }.getOrElse { chineseNumToInt(num) } - } return -1 }