|
@@ -8,15 +8,16 @@ import android.view.View
|
|
|
import android.view.ViewGroup
|
|
|
import android.widget.FrameLayout
|
|
|
import com.guadou.cs_cptservices.R
|
|
|
-import com.guadou.lib_baselib.base.activity.BaseVMActivity
|
|
|
-import com.guadou.lib_baselib.base.vm.BaseViewModel
|
|
|
+import com.guadou.cs_cptservices.base.activity.YYBaseVDBActivity
|
|
|
+import com.guadou.cs_cptservices.databinding.ActivityGlobalWebBinding
|
|
|
+import com.guadou.lib_baselib.base.vm.EmptyViewModel
|
|
|
+import com.guadou.lib_baselib.bean.DataBindingConfig
|
|
|
import com.guadou.lib_baselib.ext.toast
|
|
|
import com.guadou.lib_baselib.utils.CheckUtil
|
|
|
import com.guadou.lib_baselib.utils.CommUtils
|
|
|
import com.guadou.lib_baselib.view.MyWebView
|
|
|
-import kotlinx.android.synthetic.main.activity_global_web.*
|
|
|
|
|
|
-class GlobalWebActivity : BaseVMActivity<BaseViewModel>() {
|
|
|
+class GlobalWebActivity : YYBaseVDBActivity<EmptyViewModel, ActivityGlobalWebBinding>() {
|
|
|
|
|
|
private var mWebtitle: String? = null
|
|
|
private var mWeburl: String? = null
|
|
@@ -34,16 +35,16 @@ class GlobalWebActivity : BaseVMActivity<BaseViewModel>() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ override fun getDataBindingConfig(): DataBindingConfig {
|
|
|
+ return DataBindingConfig(R.layout.activity_global_web)
|
|
|
+ }
|
|
|
+
|
|
|
override fun getDataFromIntent(intent: Intent) {
|
|
|
super.getDataFromIntent(intent)
|
|
|
mWebtitle = intent.getStringExtra("webTitle")
|
|
|
mWeburl = intent.getStringExtra("webUrl")
|
|
|
}
|
|
|
|
|
|
- override fun getLayoutIdRes(): Int {
|
|
|
- return R.layout.activity_global_web
|
|
|
- }
|
|
|
-
|
|
|
override fun startObserve() {
|
|
|
}
|
|
|
|
|
@@ -54,7 +55,7 @@ class GlobalWebActivity : BaseVMActivity<BaseViewModel>() {
|
|
|
|
|
|
private fun initTitles() {
|
|
|
if (!CheckUtil.isEmpty(mWebtitle)) {
|
|
|
- easy_title.title = mWebtitle
|
|
|
+ mBinding.easyTitle.title = mWebtitle
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -70,25 +71,25 @@ class GlobalWebActivity : BaseVMActivity<BaseViewModel>() {
|
|
|
mWebView!!.setOnWebChangeListener(object : MyWebView.OnWebChangeListener {
|
|
|
override fun titleChange(title: String) {
|
|
|
if (CheckUtil.isEmpty(mWebtitle)) {
|
|
|
- easy_title.title = title
|
|
|
+ mBinding.easyTitle.title = title
|
|
|
}
|
|
|
}
|
|
|
|
|
|
override fun progressChange(progress: Int) {
|
|
|
var newProgress = progress
|
|
|
if (newProgress == 100) {
|
|
|
- pb_web_view.setProgress(100)
|
|
|
+ mBinding.pbWebView.setProgress(100)
|
|
|
CommUtils.getHandler()
|
|
|
- .postDelayed({ pb_web_view.visibility = View.GONE }, 200)//0.2秒后隐藏进度条
|
|
|
- } else if (pb_web_view.visibility == View.GONE) {
|
|
|
- pb_web_view.visibility = View.VISIBLE
|
|
|
+ .postDelayed({ mBinding.pbWebView.visibility = View.GONE }, 200)//0.2秒后隐藏进度条
|
|
|
+ } else if (mBinding.pbWebView.visibility == View.GONE) {
|
|
|
+ mBinding.pbWebView.visibility = View.VISIBLE
|
|
|
}
|
|
|
//设置初始进度10,这样会显得效果真一点,总不能从1开始吧
|
|
|
if (newProgress < 10) {
|
|
|
newProgress = 10
|
|
|
}
|
|
|
//不断更新进度
|
|
|
- pb_web_view.setProgress(newProgress)
|
|
|
+ mBinding.pbWebView.setProgress(newProgress)
|
|
|
}
|
|
|
|
|
|
override fun onInnerLinkChecked() {
|
|
@@ -103,7 +104,7 @@ class GlobalWebActivity : BaseVMActivity<BaseViewModel>() {
|
|
|
if (!TextUtils.isEmpty(mWeburl))
|
|
|
mWebView!!.loadUrl(mWeburl)
|
|
|
|
|
|
- fl_content.addView(mWebView)
|
|
|
+ mBinding.flContent.addView(mWebView)
|
|
|
|
|
|
}
|
|
|
|
|
@@ -139,7 +140,7 @@ class GlobalWebActivity : BaseVMActivity<BaseViewModel>() {
|
|
|
mWebView!!.clearCache(true) //清空缓存
|
|
|
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
|
|
|
|
|
|
- fl_content.removeView(mWebView)
|
|
|
+ mBinding.flContent.removeView(mWebView)
|
|
|
|
|
|
mWebView?.removeAllViews()
|
|
|
mWebView?.destroy()
|
|
@@ -147,14 +148,12 @@ class GlobalWebActivity : BaseVMActivity<BaseViewModel>() {
|
|
|
mWebView?.removeAllViews()
|
|
|
mWebView?.destroy()
|
|
|
|
|
|
- fl_content.removeView(mWebView)
|
|
|
+ mBinding.flContent.removeView(mWebView)
|
|
|
|
|
|
}
|
|
|
mWebView = null
|
|
|
}
|
|
|
|
|
|
- //退出当前web进程
|
|
|
- // System.exit(0);
|
|
|
}
|
|
|
|
|
|
|