From 30605eaed9f539062513c5eb9746fa64866caa51 Mon Sep 17 00:00:00 2001 From: kunfei Date: Wed, 11 May 2022 09:31:54 +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/help/http/BackstageWebView.kt | 5 +++-- app/src/main/java/io/legado/app/utils/RegexExtensions.kt | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/io/legado/app/help/http/BackstageWebView.kt b/app/src/main/java/io/legado/app/help/http/BackstageWebView.kt index 1ed16c894..c90e25179 100644 --- a/app/src/main/java/io/legado/app/help/http/BackstageWebView.kt +++ b/app/src/main/java/io/legado/app/help/http/BackstageWebView.kt @@ -18,6 +18,7 @@ import org.apache.commons.text.StringEscapeUtils import splitties.init.appCtx import java.lang.ref.WeakReference import kotlin.coroutines.resume +import kotlin.coroutines.resumeWithException /** * 后台webView @@ -50,14 +51,14 @@ class BackstageWebView( override fun onError(error: Throwable) { if (!block.isCompleted) - block.cancel(error) + block.resumeWithException(error) } } runOnUI { try { load() } catch (error: Throwable) { - block.cancel(error) + block.resumeWithException(error) } } } diff --git a/app/src/main/java/io/legado/app/utils/RegexExtensions.kt b/app/src/main/java/io/legado/app/utils/RegexExtensions.kt index 188b1ea9a..9250b4db8 100644 --- a/app/src/main/java/io/legado/app/utils/RegexExtensions.kt +++ b/app/src/main/java/io/legado/app/utils/RegexExtensions.kt @@ -6,6 +6,7 @@ import kotlinx.coroutines.suspendCancellableCoroutine import splitties.init.appCtx import kotlin.concurrent.thread import kotlin.coroutines.resume +import kotlin.coroutines.resumeWithException /** * 带有超时检测的正则替换 @@ -19,7 +20,7 @@ suspend fun CharSequence.replace(regex: Regex, replacement: String, timeout: Lon val result = regex.replace(charSequence, replacement) block.resume(result) } catch (e: Exception) { - block.cancel(e) + block.resumeWithException(e) } } mainHandler.postDelayed({