pull/48/head
kunfei 5 years ago
parent e0a8544a14
commit e110a0d3bf
  1. 9
      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<WebView> = WeakReference(webView)
override fun run() {
mWebView.get()?.evaluateJavascript(mJavaScript) {
@ -187,11 +188,19 @@ 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)
}
}
}
private class SnifferWebClient(
private val params: AjaxParams,

Loading…
Cancel
Save