|
@@ -1,10 +1,12 @@
|
|
|
package com.swago.baseswago.dialog
|
|
|
|
|
|
import android.content.Intent
|
|
|
+import android.graphics.Color
|
|
|
import android.os.Bundle
|
|
|
import android.view.Gravity
|
|
|
import android.view.View
|
|
|
import android.view.View.OnClickListener
|
|
|
+import android.webkit.JavascriptInterface
|
|
|
import android.webkit.WebViewClient
|
|
|
import com.alibaba.android.arouter.launcher.ARouter
|
|
|
import com.swago.baseswago.constant.ARouteConstant
|
|
@@ -16,7 +18,9 @@ import com.swago.baseswago.util.SpUtil
|
|
|
import com.swago.baseswago.util.UserInfo
|
|
|
|
|
|
class TodayTrafficDialog : BaseXDFragment<DialogTodayTrafficBinding>() {
|
|
|
-
|
|
|
+ private val jsLoad by lazy {
|
|
|
+ JSLoad()
|
|
|
+ }
|
|
|
init {
|
|
|
setGravity(Gravity.CENTER)
|
|
|
setDimAmount(0.5f)
|
|
@@ -33,12 +37,29 @@ class TodayTrafficDialog : BaseXDFragment<DialogTodayTrafficBinding>() {
|
|
|
}
|
|
|
|
|
|
override fun initOther() {
|
|
|
- binding.webview.settings.javaScriptEnabled = true
|
|
|
- binding.webview.webViewClient = WebViewClient()
|
|
|
- binding.webview.loadUrl("https://www.baidu.com")
|
|
|
+ binding.webview.apply {
|
|
|
+ settings.javaScriptEnabled = true
|
|
|
+ addJavascriptInterface(jsLoad, "jsLoad")
|
|
|
+ settings.allowFileAccess = true
|
|
|
+ settings.useWideViewPort = true
|
|
|
+ settings.loadWithOverviewMode = true
|
|
|
+ settings.javaScriptCanOpenWindowsAutomatically = true//设置允许JS弹窗
|
|
|
+ settings.domStorageEnabled = true
|
|
|
+ isHorizontalScrollBarEnabled = true
|
|
|
+ isVerticalScrollBarEnabled = true
|
|
|
+ setBackgroundColor(Color.TRANSPARENT)
|
|
|
+ webViewClient = WebViewClient()
|
|
|
+ loadUrl("https://www.baidu.com")
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
override fun initLiveData() {
|
|
|
|
|
|
}
|
|
|
+ inner class JSLoad {
|
|
|
+ @JavascriptInterface
|
|
|
+ fun closeDialog() {
|
|
|
+ dismissAllowingStateLoss()
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|