liugl
2020-11-18 16d807930e47fcab5a7e773046daad78e04849e2
app/src/main/java/com/okgoincar/slab/SlabMainActivity.kt
@@ -91,7 +91,6 @@
    }
    override fun initView() {
        tv_title_top.text = "服 务 监 督 卡 I"
        if (NetUtils.isNetworkConnected(this)){
            setTitleText("OK出行司机")
            showHeader(false)
@@ -107,7 +106,7 @@
                callVersion()
            }
        }else{
            toast("无网络")
            showNoneNetDialog()
        }
    }
@@ -125,6 +124,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 +147,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 +154,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 +171,7 @@
    private fun showUI(data: UserInfoBean?) {
        data?.let {
            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 +345,16 @@
                    toast("收到显示屏信息")
                }
            }
            BaseEvent.UPDATA_MAIN_CAR->{
                try {
                    mainFragment.refresh()
                }catch (e:Exception){
                }
            }
            BaseEvent.ERROR_INFO -> {
                try {
                    mainFragment.refresh()
                }catch (e:Exception){
                }
            }
        }
@@ -373,16 +383,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 +411,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 +421,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()