|
@@ -1,21 +1,34 @@
|
|
|
package com.swago.baseswago.dialog
|
|
|
|
|
|
+import android.graphics.Bitmap
|
|
|
import android.graphics.Color
|
|
|
+import android.os.Build
|
|
|
import android.os.Bundle
|
|
|
import android.view.Gravity
|
|
|
+import android.view.ViewGroup
|
|
|
import android.webkit.JavascriptInterface
|
|
|
+import android.webkit.WebChromeClient
|
|
|
+import android.webkit.WebSettings
|
|
|
+import android.webkit.WebView
|
|
|
import android.webkit.WebViewClient
|
|
|
+import androidx.constraintlayout.widget.ConstraintLayout
|
|
|
+import androidx.transition.Visibility
|
|
|
+import com.google.firebase.firestore.core.View
|
|
|
import com.swago.baseswago.databinding.DialogTodayTrafficBinding
|
|
|
+import com.swago.baseswago.util.DpPxUtil
|
|
|
+import com.swago.baseswago.util.SwagoInfo
|
|
|
+import com.swago.baseswago.util.UserInfo
|
|
|
+import org.json.JSONObject
|
|
|
|
|
|
-class TodayTrafficDialog : BaseXDFragment<DialogTodayTrafficBinding>() {
|
|
|
+class TodayTrafficDialog : BaseStoreDFragment<DialogTodayTrafficBinding>() {
|
|
|
private var showDialog:Boolean = true
|
|
|
private val jsLoad by lazy {
|
|
|
JSLoad()
|
|
|
}
|
|
|
init {
|
|
|
setGravity(Gravity.CENTER)
|
|
|
- setDimAmount(0f)
|
|
|
- setCanCancel(false)
|
|
|
+ setDimAmount(0.6f)
|
|
|
+ setCanCancel(true)
|
|
|
setHeightMatchParent()
|
|
|
}
|
|
|
|
|
@@ -29,18 +42,54 @@ class TodayTrafficDialog : BaseXDFragment<DialogTodayTrafficBinding>() {
|
|
|
}
|
|
|
|
|
|
override fun initOther() {
|
|
|
- binding.webview.apply {
|
|
|
+ binding?.loadingProgress?.visibility = android.view.View.VISIBLE
|
|
|
+ binding?.webview?.apply {
|
|
|
+ //设置大小
|
|
|
+ val params = ConstraintLayout.LayoutParams(
|
|
|
+ ViewGroup.LayoutParams.MATCH_PARENT,
|
|
|
+ ViewGroup.LayoutParams.MATCH_PARENT
|
|
|
+ )
|
|
|
+ params.topMargin = DpPxUtil.getScreenHeight()/6
|
|
|
+ this.layoutParams = params
|
|
|
+ try {
|
|
|
+ val jsonObject = JSONObject()
|
|
|
+ jsonObject.put("TokenParam", UserInfo.getLoginModel()?.token?:"")
|
|
|
+ jsonObject.put("UserIdParam", UserInfo.getUserInfo()?.id?:"")
|
|
|
+ jsonObject.put("LocaleParam", SwagoInfo.getLanguageCode())
|
|
|
+ jsonObject.put("AppVersionParam", SwagoInfo.getVersionCode())
|
|
|
+ jsonObject.put("ClientParam", SwagoInfo.getAppClient())
|
|
|
+ jsonObject.put("ChannelParam", SwagoInfo.getChannel())
|
|
|
+ jsonObject.put("DeviceParam", SwagoInfo.getDeviceInfo())
|
|
|
+ settings.userAgentString = settings.userAgentString + jsonObject.toString()
|
|
|
+ } catch (e: Exception) {
|
|
|
+ e.printStackTrace()
|
|
|
+ }
|
|
|
+
|
|
|
+ if (Build.VERSION.SDK_INT >= 21) {
|
|
|
+ settings.mixedContentMode = WebSettings.MIXED_CONTENT_ALWAYS_ALLOW
|
|
|
+ }
|
|
|
settings.javaScriptEnabled = true
|
|
|
addJavascriptInterface(jsLoad, "melive")
|
|
|
+ settings.allowUniversalAccessFromFileURLs = true
|
|
|
settings.allowFileAccess = true
|
|
|
+ settings.allowFileAccessFromFileURLs = true
|
|
|
settings.useWideViewPort = true
|
|
|
settings.loadWithOverviewMode = true
|
|
|
settings.javaScriptCanOpenWindowsAutomatically = true//设置允许JS弹窗
|
|
|
settings.domStorageEnabled = true
|
|
|
+ settings.cacheMode = WebSettings.LOAD_CACHE_ELSE_NETWORK
|
|
|
+ settings.domStorageEnabled = true
|
|
|
isHorizontalScrollBarEnabled = true
|
|
|
isVerticalScrollBarEnabled = true
|
|
|
+ settings.databaseEnabled = true
|
|
|
setBackgroundColor(Color.TRANSPARENT)
|
|
|
- webViewClient = WebViewClient()
|
|
|
+ webViewClient = object : WebViewClient(){
|
|
|
+ override fun onPageFinished(view: WebView?, url: String?) {
|
|
|
+ super.onPageFinished(view, url)
|
|
|
+ binding?.loadingProgress?.visibility = android.view.View.GONE
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
loadUrl("http://test-h5.swago.cn/checkIn")
|
|
|
}
|
|
|
}
|