liugl
2020-11-18 16d807930e47fcab5a7e773046daad78e04849e2
app/src/main/java/com/okgoincar/slab/SlabMainActivity.kt
@@ -106,7 +106,7 @@
                callVersion()
            }
        }else{
            toast("无网络")
            showNoneNetDialog()
        }
    }
@@ -124,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)){
@@ -137,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 {
@@ -341,11 +345,16 @@
                    toast("收到显示屏信息")
                }
            }
            BaseEvent.UPDATA_MAIN_CAR->{
                try {
                    mainFragment.refresh()
                }catch (e:Exception){
                }
            }
            BaseEvent.ERROR_INFO -> {
                try {
                    mainFragment.refresh()
                }catch (e:Exception){
                }
            }
        }
@@ -374,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("后台开始下载,请等待")
@@ -403,8 +413,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 +420,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 +436,8 @@
                CacheKey.putKeyStr("serverId", bean.data.serverId.toString())
                CacheKey.putKeyStr("terminalName", bean.data.terminalId.toString())
                ok()
            }) {
                ok()
            }
        } else {
            ok()