liugl
2020-12-12 e95f159957e16d82eabc2f6e26f5d17302d7865f
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.*
@@ -106,7 +107,7 @@
                callVersion()
            }
        }else{
            toast("无网络")
            showNoneNetDialog()
        }
    }
@@ -124,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)){
@@ -137,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 {
@@ -167,6 +172,7 @@
    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)
@@ -341,11 +347,16 @@
                    toast("收到显示屏信息")
                }
            }
            BaseEvent.UPDATA_MAIN_CAR->{
                try {
                    mainFragment.refresh()
                }catch (e:Exception){
                }
            }
            BaseEvent.ERROR_INFO -> {
                try {
                    mainFragment.refresh()
                }catch (e:Exception){
                }
            }
        }
@@ -374,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("后台开始下载,请等待")
@@ -403,8 +415,6 @@
            var map = getMapByAny()
            map["taxiAptitudeCard"] = identification
            callNet(this, Api.loginByTaxiAptitudeCard, map,{
                ok()
            }) {
                var bean = Gson().fromJson<LoginBean>(it, LoginBean::class.java)
                CacheKey.putKeyStr("identification", identification)
                CacheKey.putKeyStr("appid", bean.data.appid)
@@ -412,12 +422,14 @@
                CacheKey.putKeyStr("userId", bean.data.id.toString())
                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(true, Api.loginByTaxiAptitudeCard, map) {
            callNet(this, Api.loginByTaxiAptitudeCard, map,{
                var bean = Gson().fromJson<LoginBean>(it, LoginBean::class.java)
                CacheKey.putKeyStr("identification", identification)
                CacheKey.putKeyStr("appid", bean.data.appid)
@@ -426,6 +438,8 @@
                CacheKey.putKeyStr("serverId", bean.data.serverId.toString())
                CacheKey.putKeyStr("terminalName", bean.data.terminalId.toString())
                ok()
            }) {
                ok()
            }
        } else {
            ok()