From 1681c8891af78428ce5f691543a6f1116b9560d9 Mon Sep 17 00:00:00 2001 From: gedoor Date: Sun, 26 Sep 2021 11:17:56 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/help/http/BackstageWebView.kt | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/io/legado/app/help/http/BackstageWebView.kt b/app/src/main/java/io/legado/app/help/http/BackstageWebView.kt index 9d8e75460..da88b0156 100644 --- a/app/src/main/java/io/legado/app/help/http/BackstageWebView.kt +++ b/app/src/main/java/io/legado/app/help/http/BackstageWebView.kt @@ -58,19 +58,23 @@ class BackstageWebView( } private fun load() { - mWebView = createWebView().apply { + val webView = createWebView() + mWebView = webView + try { when { !html.isNullOrEmpty() -> if (url.isNullOrEmpty()) { - loadData(html, "text/html", getEncoding()) + webView.loadData(html, "text/html", getEncoding()) } else { - loadDataWithBaseURL(url, html, "text/html", getEncoding(), url) + webView.loadDataWithBaseURL(url, html, "text/html", getEncoding(), url) } else -> if (headerMap == null) { - loadUrl(url!!) + webView.loadUrl(url!!) } else { - loadUrl(url!!, headerMap) + webView.loadUrl(url!!, headerMap) } } + } catch (e: Exception) { + callback?.onError(e) } }