去除webView错误事件

pull/279/head
gedoor 4 years ago
parent 04f9906345
commit 83af11a251
  1. 55
      app/src/main/java/io/legado/app/help/http/AjaxWebView.kt

@ -1,12 +1,14 @@
package io.legado.app.help.http package io.legado.app.help.http
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.os.Build
import android.os.Handler import android.os.Handler
import android.os.Looper import android.os.Looper
import android.os.Message import android.os.Message
import android.text.TextUtils import android.text.TextUtils
import android.webkit.* import android.webkit.CookieManager
import android.webkit.WebSettings
import android.webkit.WebView
import android.webkit.WebViewClient
import io.legado.app.App import io.legado.app.App
import io.legado.app.constant.AppConst import io.legado.app.constant.AppConst
import org.apache.commons.text.StringEscapeUtils import org.apache.commons.text.StringEscapeUtils
@ -142,30 +144,6 @@ class AjaxWebView {
handler.postDelayed(runnable, 1000) handler.postDelayed(runnable, 1000)
} }
override fun onReceivedError(
view: WebView,
errorCode: Int,
description: String,
failingUrl: String
) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
handler.obtainMessage(MSG_ERROR, Exception(description))
.sendToTarget()
}
}
override fun onReceivedError(
view: WebView,
request: WebResourceRequest,
error: WebResourceError
) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
handler.obtainMessage(
MSG_ERROR,
Exception(error.description.toString())
).sendToTarget()
}
}
} }
private class EvalJsRunnable( private class EvalJsRunnable(
@ -213,31 +191,6 @@ class AjaxWebView {
} }
} }
override fun onReceivedError(
view: WebView,
errorCode: Int,
description: String,
failingUrl: String
) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
handler.obtainMessage(MSG_ERROR, Exception(description))
.sendToTarget()
}
}
override fun onReceivedError(
view: WebView,
request: WebResourceRequest,
error: WebResourceError
) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
handler.obtainMessage(
MSG_ERROR,
Exception(error.description.toString())
).sendToTarget()
}
}
override fun onPageFinished(view: WebView, url: String) { override fun onPageFinished(view: WebView, url: String) {
params.setCookie(url) params.setCookie(url)
if (params.hasJavaScript()) { if (params.hasJavaScript()) {

Loading…
Cancel
Save