From e110a0d3bf7e633eac6c22ded46463d78ec678f4 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 8 Nov 2019 22:34:30 +0800 Subject: [PATCH] up --- .../main/java/io/legado/app/help/http/AjaxWebView.kt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/help/http/AjaxWebView.kt b/app/src/main/java/io/legado/app/help/http/AjaxWebView.kt index a871ee801..deae70382 100644 --- a/app/src/main/java/io/legado/app/help/http/AjaxWebView.kt +++ b/app/src/main/java/io/legado/app/help/http/AjaxWebView.kt @@ -179,6 +179,7 @@ class AjaxWebView { private val mJavaScript: String, private val handler: Handler ) : Runnable { + var retry = 0 private val mWebView: WeakReference = WeakReference(webView) override fun run() { mWebView.get()?.evaluateJavascript(mJavaScript) { @@ -187,9 +188,17 @@ class AjaxWebView { handler.obtainMessage(MSG_SUCCESS, Response(url, content)) .sendToTarget() handler.removeCallbacks(this) + return@evaluateJavascript } + if (retry > 30) { + handler.obtainMessage(MSG_ERROR, Exception("time out")) + .sendToTarget() + handler.removeCallbacks(this) + return@evaluateJavascript + } + retry++ + handler.postDelayed(this, 1000) } - handler.postDelayed(this, 1000) } }