feat: 优化代码

pull/123/head
kunfei 5 years ago
parent 263b3e2843
commit 78781ff757
  1. 16
      app/src/main/java/io/legado/app/help/http/AjaxWebView.kt

@ -9,7 +9,11 @@ import android.os.Message
import android.text.TextUtils import android.text.TextUtils
import android.webkit.* import android.webkit.*
import io.legado.app.App import io.legado.app.App
import io.legado.app.R
import io.legado.app.constant.AppConst import io.legado.app.constant.AppConst
import io.legado.app.lib.dialogs.alert
import io.legado.app.lib.dialogs.cancelButton
import io.legado.app.lib.dialogs.okButton
import org.apache.commons.text.StringEscapeUtils import org.apache.commons.text.StringEscapeUtils
import java.lang.ref.WeakReference import java.lang.ref.WeakReference
@ -169,7 +173,11 @@ class AjaxWebView {
} }
override fun onReceivedSslError(view: WebView, handler: SslErrorHandler, error: SslError) { override fun onReceivedSslError(view: WebView, handler: SslErrorHandler, error: SslError) {
handler.proceed() App.INSTANCE.alert(titleResource = R.string.sure) {
message = "${view.url}证书不匹配,是否继续访问"
okButton { handler.proceed() }
cancelButton { handler.cancel() }
}.show()
} }
} }
@ -243,7 +251,11 @@ class AjaxWebView {
} }
override fun onReceivedSslError(view: WebView, handler: SslErrorHandler, error: SslError) { override fun onReceivedSslError(view: WebView, handler: SslErrorHandler, error: SslError) {
handler.proceed() App.INSTANCE.alert(titleResource = R.string.sure) {
message = "${view.url}证书不匹配,是否继续访问"
okButton { handler.proceed() }
cancelButton { handler.cancel() }
}.show()
} }
override fun onPageFinished(view: WebView, url: String) { override fun onPageFinished(view: WebView, url: String) {

Loading…
Cancel
Save