mirror of
https://github.com/gedoor/legado.git
synced 2025-08-10 00:52:30 +00:00
优化
This commit is contained in:
@@ -10,6 +10,7 @@ import kotlinx.coroutines.Dispatchers.IO
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import kotlinx.coroutines.suspendCancellableCoroutine
|
||||
import splitties.init.appCtx
|
||||
import java.util.regex.Matcher
|
||||
import kotlin.coroutines.resume
|
||||
import kotlin.coroutines.resumeWithException
|
||||
|
||||
@@ -36,7 +37,8 @@ fun CharSequence.replace(regex: Regex, replacement: String, timeout: Long): Stri
|
||||
bindings["result"] = matcher.group()
|
||||
eval(replacement1, bindings)
|
||||
}.toString()
|
||||
matcher.appendReplacement(stringBuffer, jsResult)
|
||||
val quotedResult = Matcher.quoteReplacement(jsResult)
|
||||
matcher.appendReplacement(stringBuffer, quotedResult)
|
||||
} else {
|
||||
matcher.appendReplacement(stringBuffer, replacement1)
|
||||
}
|
||||
@@ -49,7 +51,8 @@ fun CharSequence.replace(regex: Regex, replacement: String, timeout: Long): Stri
|
||||
}
|
||||
handler.postDelayed(timeout) {
|
||||
if (coroutine.isActive) {
|
||||
val timeoutMsg = "替换超时,3秒后还未结束将重启应用\n替换规则$regex\n替换内容:${this}"
|
||||
val timeoutMsg =
|
||||
"替换超时,3秒后还未结束将重启应用\n替换规则$regex\n替换内容:$charSequence"
|
||||
val exception = RegexTimeoutException(timeoutMsg)
|
||||
block.cancel(exception)
|
||||
appCtx.longToastOnUi(timeoutMsg)
|
||||
|
||||
Reference in New Issue
Block a user