|
@@ -5,8 +5,11 @@ import android.content.pm.ActivityInfo
|
|
|
import android.graphics.Bitmap
|
|
|
import android.os.Build
|
|
|
import android.os.Bundle
|
|
|
-import android.util.Log
|
|
|
-import android.webkit.*
|
|
|
+import android.text.TextUtils
|
|
|
+import android.webkit.WebResourceRequest
|
|
|
+import android.webkit.WebSettings
|
|
|
+import android.webkit.WebView
|
|
|
+import android.webkit.WebViewClient
|
|
|
import com.alibaba.android.arouter.facade.annotation.Route
|
|
|
import com.yingyangfly.baselib.base.BaseActivity
|
|
|
import com.yingyangfly.baselib.ext.setOnSingleClickListener
|
|
@@ -47,16 +50,8 @@ class WebviewActivity : BaseActivity<ActivityWebviewBinding>() {
|
|
|
* sessionStorage 用来存储与页面相关的数据,它在页面关闭后无法使用。而 localStorage 则持久存在,在页面关闭后也可以使用。
|
|
|
*/
|
|
|
webSettings?.domStorageEnabled = true
|
|
|
-
|
|
|
-
|
|
|
// 通过addJavascriptInterface()将Java对象映射到JS对象 下面一行代码是 JS调用原生方法
|
|
|
binding.web.addJavascriptInterface(AndroidToJs(this), "android")
|
|
|
-// binding.web.addJavascriptInterface(AndroidToJs(this), "callbackImgHandle")
|
|
|
-// binding.web.addJavascriptInterface(AndroidToJs(this), "callbackBackHandle")
|
|
|
-
|
|
|
- binding.web.evaluateJavascript("callbackHandle"
|
|
|
- ) { value -> Log.e("wpp", "----" + value) }
|
|
|
-
|
|
|
binding.web.isDrawingCacheEnabled = true
|
|
|
binding.web.buildDrawingCache()
|
|
|
binding.web.buildLayer()
|
|
@@ -92,7 +87,7 @@ class WebviewActivity : BaseActivity<ActivityWebviewBinding>() {
|
|
|
super.onPageStarted(view, url, favicon)
|
|
|
}
|
|
|
}
|
|
|
- if (url.isNullOrEmpty().not()) {
|
|
|
+ if (TextUtils.isEmpty(url).not()) {
|
|
|
//访问网页
|
|
|
binding.web.loadUrl(url!!)
|
|
|
}
|