From c406be78df4545941c8a4a96ac7e572b62d0977c Mon Sep 17 00:00:00 2001
From: liugl <liugl@sinata.cn>
Date: 星期六, 12 十二月 2020 11:21:39 +0800
Subject: [PATCH] 1:新增版本号

---
 app/src/main/java/com/okgoincar/slab/SlabMainActivity.kt |   69 +++++++++++++++++++++-------------
 1 files changed, 43 insertions(+), 26 deletions(-)

diff --git a/app/src/main/java/com/okgoincar/slab/SlabMainActivity.kt b/app/src/main/java/com/okgoincar/slab/SlabMainActivity.kt
index d38a759..c3c0447 100644
--- a/app/src/main/java/com/okgoincar/slab/SlabMainActivity.kt
+++ b/app/src/main/java/com/okgoincar/slab/SlabMainActivity.kt
@@ -31,6 +31,7 @@
 import com.okgoincar.slab.util.DialogUtil
 import com.okgoincar.utils.DateUtil
 import com.okgoincar.utils.EasePopup.EasyPopup
+import com.okgoincar.utils.PackageUtil
 import com.okgoincar.utils.download.DownloadUtil
 import com.okgoincar.utils.glide.GlideUtil
 import kotlinx.android.synthetic.main.dialog_sure_and_del_slab.view.*
@@ -91,7 +92,6 @@
     }
 
     override fun initView() {
-        tv_title_top.text = "服 务 监 督 卡 I"
         if (NetUtils.isNetworkConnected(this)){
             setTitleText("OK出行司机")
             showHeader(false)
@@ -107,7 +107,7 @@
                 callVersion()
             }
         }else{
-            toast("无网络")
+            showNoneNetDialog()
         }
     }
 
@@ -125,6 +125,16 @@
 
     override fun onResume() {
         super.onResume()
+        showNoneNetDialog()
+        try {
+            mainFragment?.refresh()
+            callPersion()
+        }catch (e:Exception){
+
+        }
+    }
+
+    fun showNoneNetDialog(){
         if (!NetUtils.isNetworkConnected(this)){
             popup = getSlabDelAndSurePopWindow(this,"刷新","取消","网络不通畅,是否刷新页面?",{}){
                 if (!NetUtils.isNetworkConnected(this)){
@@ -138,12 +148,6 @@
                 popup?.showCenter(window.decorView)
             }
         }
-        try {
-            mainFragment?.refresh()
-        }catch (e:Exception){
-
-        }
-
     }
 
     fun getSlabDelAndSurePopWindow(context: Context,sureStr:String,cancelStr:String,content:String,clickClose :() -> Unit,clickSure:() -> Unit): EasyPopup {
@@ -151,6 +155,7 @@
         var view = dialog.contentView
         view.tv_close_base.text = cancelStr
         view.tv_sure_base.text = sureStr
+        view.tv_close_base.gone()
         view.tv_close_base.setOnClickListener {
             dialog.dismiss()
             clickClose()
@@ -167,6 +172,8 @@
 
     private fun showUI(data: UserInfoBean?) {
         data?.let {
+            textView_version.text ="版本-V"+PackageUtil.getVersionName(this)
+            tv_title_top.text = "服 务 监 督 卡"
             if (data.taxiAptitudeCard.length > 7){
                 tv_code_num.text  = "资格证号:"+data.taxiAptitudeCard.substring(0,3)+"*******"+data.taxiAptitudeCard.substring(data.taxiAptitudeCard.length-4,data.taxiAptitudeCard.length)
             }else{
@@ -340,11 +347,16 @@
                     toast("收到显示屏信息")
                 }
             }
+            BaseEvent.UPDATA_MAIN_CAR->{
+                try {
+                    mainFragment.refresh()
+                }catch (e:Exception){
+                }
+            }
             BaseEvent.ERROR_INFO -> {
                 try {
                     mainFragment.refresh()
                 }catch (e:Exception){
-
                 }
             }
         }
@@ -373,16 +385,17 @@
             if (bean.data.version != "" && bean.data.version != Utils.getAppVersion(this)) {
                 if (bean.data.mandatory == 0) {
                     var pop =
-                        DialogUtil.getSlabDelAndSurePopWindow(this, "确定", "取消", "有新版本是否更新", {}) {
+                        DialogUtil.getSlabDelAndSurePopWindow(true,this, "确定", "取消", "有新版本是否更新", {}) {
                             DownloadUtil(this).downloadAPK(bean.data.url, "ok出行车载端")
                         }
                     pop.showCenter(window.decorView)
                 } else {
                     var pop = DialogUtil.getSlabDelAndSurePopWindow(
+                        false,
                         this,
                         "确定",
                         "取消",
-                        "版本已过时,是否强制升级?",
+                        "版本已过时,强制升级!",
                         {}) {
                         DownloadUtil(this).downloadAPK(bean.data.url, "ok出行车载端")
                         toast("后台开始下载,请等待")
@@ -400,21 +413,8 @@
         var identification = CacheKey.getKeyStr("identification")
         if (jobNum.isNotEmpty()) {
             var map = getMapByAny()
-            map["jobNum"] = jobNum
-            callNet(true, Api.loginByJobNumber, map) {
-                var bean = gson.fromJson<LoginBean>(it, LoginBean::class.java)
-                CacheKey.putKeyStr("jobNum", jobNum)
-                CacheKey.putKeyStr("appid", bean.data.appid)
-                CacheKey.putKeyStr("token", bean.data.token)
-                CacheKey.putKeyStr("userId", bean.data.id.toString())
-                CacheKey.putKeyStr("serverId", bean.data.serverId.toString())
-                CacheKey.putKeyStr("terminalName", bean.data.terminalId.toString())
-                ok()
-            }
-        } else if (identification.isNotEmpty()) {
-            var map = getMapByAny()
-            map["identification"] = identification
-            callNet(true, Api.loginByIdentification, map) {
+            map["taxiAptitudeCard"] = identification
+            callNet(this, Api.loginByTaxiAptitudeCard, map,{
                 var bean = Gson().fromJson<LoginBean>(it, LoginBean::class.java)
                 CacheKey.putKeyStr("identification", identification)
                 CacheKey.putKeyStr("appid", bean.data.appid)
@@ -423,6 +423,23 @@
                 CacheKey.putKeyStr("serverId", bean.data.serverId.toString())
                 CacheKey.putKeyStr("terminalName", bean.data.terminalId.toString())
                 ok()
+            }) {
+                ok()
+            }
+        } else if (identification.isNotEmpty()) {
+            var map = getMapByAny()
+            map["taxiAptitudeCard"] = identification
+            callNet(this, Api.loginByTaxiAptitudeCard, map,{
+                var bean = Gson().fromJson<LoginBean>(it, LoginBean::class.java)
+                CacheKey.putKeyStr("identification", identification)
+                CacheKey.putKeyStr("appid", bean.data.appid)
+                CacheKey.putKeyStr("token", bean.data.token)
+                CacheKey.putKeyStr("userId", bean.data.id.toString())
+                CacheKey.putKeyStr("serverId", bean.data.serverId.toString())
+                CacheKey.putKeyStr("terminalName", bean.data.terminalId.toString())
+                ok()
+            }) {
+                ok()
             }
         } else {
             ok()

--
Gitblit v1.7.1