kunfei 4 лет назад
Родитель
Сommit
5fa7b62849

+ 3 - 2
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 splitties.init.appCtx
 import java.lang.ref.WeakReference
 import java.lang.ref.WeakReference
 import kotlin.coroutines.resume
 import kotlin.coroutines.resume
+import kotlin.coroutines.resumeWithException
 
 
 /**
 /**
  * 后台webView
  * 后台webView
@@ -50,14 +51,14 @@ class BackstageWebView(
 
 
             override fun onError(error: Throwable) {
             override fun onError(error: Throwable) {
                 if (!block.isCompleted)
                 if (!block.isCompleted)
-                    block.cancel(error)
+                    block.resumeWithException(error)
             }
             }
         }
         }
         runOnUI {
         runOnUI {
             try {
             try {
                 load()
                 load()
             } catch (error: Throwable) {
             } catch (error: Throwable) {
-                block.cancel(error)
+                block.resumeWithException(error)
             }
             }
         }
         }
     }
     }

+ 2 - 1
app/src/main/java/io/legado/app/utils/RegexExtensions.kt

@@ -6,6 +6,7 @@ import kotlinx.coroutines.suspendCancellableCoroutine
 import splitties.init.appCtx
 import splitties.init.appCtx
 import kotlin.concurrent.thread
 import kotlin.concurrent.thread
 import kotlin.coroutines.resume
 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)
                 val result = regex.replace(charSequence, replacement)
                 block.resume(result)
                 block.resume(result)
             } catch (e: Exception) {
             } catch (e: Exception) {
-                block.cancel(e)
+                block.resumeWithException(e)
             }
             }
         }
         }
         mainHandler.postDelayed({
         mainHandler.postDelayed({