替换规则添加超时字段

pull/1861/head
kunfei 3 years ago
parent 911eb83c3f
commit e0b64f8a4a
  1. 1
      app/src/main/assets/updateLog.md
  2. 6
      app/src/main/java/io/legado/app/data/entities/BookChapter.kt
  3. 7
      app/src/main/java/io/legado/app/data/entities/ReplaceRule.kt
  4. 6
      app/src/main/java/io/legado/app/help/ContentProcessor.kt
  5. 2
      app/src/main/java/io/legado/app/ui/replace/edit/ReplaceEditActivity.kt

@ -16,6 +16,7 @@
* js添加 getVerificationCode startBrowserAwait
* 监测网络变化及时更新web服务的IP
* 优化在线tts导入
* 替换规则添加超时字段
**2022/05/02**

@ -98,7 +98,11 @@ data class BookChapter(
if (item.pattern.isNotEmpty()) {
try {
val mDisplayTitle = if (item.isRegex) {
displayTitle.replace(item.pattern.toRegex(), item.replacement, 1000)
displayTitle.replace(
item.pattern.toRegex(),
item.replacement,
item.getValidTimeoutMillisecond()
)
} else {
displayTitle.replace(item.pattern, item.replacement)
}

@ -84,4 +84,11 @@ data class ReplaceRule(
}
return true
}
fun getValidTimeoutMillisecond(): Long {
if (timeoutMillisecond <= 0) {
return 3000L
}
return timeoutMillisecond
}
}

@ -137,7 +137,11 @@ class ContentProcessor private constructor(
if (item.pattern.isNotEmpty()) {
kotlin.runCatching {
mContent = if (item.isRegex) {
mContent.replace(item.pattern.toRegex(), item.replacement, 3000L)
mContent.replace(
item.pattern.toRegex(),
item.replacement,
item.getValidTimeoutMillisecond()
)
} else {
mContent.replace(item.pattern, item.replacement)
}

@ -110,7 +110,7 @@ class ReplaceEditActivity :
replaceRule.scopeTitle = cbScopeTitle.isChecked
replaceRule.scopeContent = cbScopeContent.isChecked
replaceRule.scope = etScope.text.toString()
replaceRule.timeoutMillisecond = etTimeout.text.toString().toLong()
replaceRule.timeoutMillisecond = etTimeout.text.toString().ifEmpty { "3000" }.toLong()
return replaceRule
}

Loading…
Cancel
Save