From 386c12bc80d17252ea05b7bf1cb2e85db2e46767 Mon Sep 17 00:00:00 2001 From: liugl <liugl@sinata.cn> Date: 星期五, 07 八月 2020 13:13:41 +0800 Subject: [PATCH] 8.7 --- app/src/main/java/com/okgoincar/slab/SlabMainActivity.kt | 110 ++++++++++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 93 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/com/okgoincar/slab/SlabMainActivity.kt b/app/src/main/java/com/okgoincar/slab/SlabMainActivity.kt index cef0b9c..e3e7b79 100644 --- a/app/src/main/java/com/okgoincar/slab/SlabMainActivity.kt +++ b/app/src/main/java/com/okgoincar/slab/SlabMainActivity.kt @@ -1,5 +1,6 @@ package com.okgoincar.slab +import android.content.Context import android.content.Intent import android.content.IntentFilter import android.os.Bundle @@ -9,10 +10,7 @@ import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import cn.sinata.rxnetty.NettyClient -import cn.sinata.xldutils.utils.Utils -import cn.sinata.xldutils.utils.clickDelay -import cn.sinata.xldutils.utils.getNowTimeBlack -import cn.sinata.xldutils.utils.textColor +import cn.sinata.xldutils.utils.* import com.amap.api.location.AMapLocation import com.amap.api.location.AMapLocationListener import com.okgoincar.netUtls.callNet @@ -26,15 +24,19 @@ import com.okgoincar.base.MyApplication import com.okgoincar.bean.* import com.okgoincar.netUtls.Api +import com.okgoincar.netUtls.sendAudio import com.okgoincar.slab.event.SlabMineEventActivity import com.okgoincar.slab.util.DialogUtil import com.okgoincar.utils.DateUtil import com.okgoincar.utils.download.DownloadUtil import com.okgoincar.utils.glide.GlideUtil +import kotlinx.android.synthetic.main.slab_activity_login.* import kotlinx.android.synthetic.main.slab_activity_main.* +import kotlinx.android.synthetic.main.slab_activity_main.tv_name import org.greenrobot.eventbus.EventBus import org.jetbrains.anko.startActivity import org.jetbrains.anko.toast +import java.lang.Exception class SlabMainActivity : MySlabBaseActivity(), AMapLocationListener { @@ -89,13 +91,17 @@ setTitleText("OK出行司机") showHeader(false) showTitle(false) - addFragment(mainFragment, R.id.rl_container) - AMapKit.initLocation(this, this) - initCall() - NettyClient.getInstance().startService() - callPersion() - showOrder("2221", "2", 100, 2) - callVersion() + callLogin { + view_mode.isSelected = !getNowTimeBlack() + addFragment(mainFragment, R.id.rl_container) + AMapKit.initLocation(this, this) + initCall() + NettyClient.getInstance().startService() + callPersion() +// showOrder("2221", "2", 100, 2) + callVersion() + } + //重重新登录 用来上线 } @@ -109,7 +115,11 @@ override fun onResume() { super.onResume() - mainFragment.refresh() + try { + mainFragment.refresh() + }catch (e:Exception){ + + } } private fun showUI(data: UserInfoBean?) { @@ -213,8 +223,26 @@ startActivity<SlabMineEventActivity>() } + tv_title_top.clickDelay { + } + + view_mode.clickDelay { + view_mode.isSelected = !view_mode.isSelected + if (getNowTimeBlack()) { + CacheKey.putKeyStr("date_mode", System.currentTimeMillis().toString()) + CacheKey.putKeyStr("mode_now_time", "1")//记录为点击切换的颜色 1 白色 2 黑色 + setBlackMode(false) + } else { + CacheKey.putKeyStr("date_mode", System.currentTimeMillis().toString()) + CacheKey.putKeyStr("mode_now_time", "2") + setBlackMode(true) + } + + + } tv_car.clickDelay { + // if (homeDataBean?.data?.work == 1) { // callNet(true, Api.work2, getMapByAny()) { // homeDataBean?.data?.work = 2 @@ -244,7 +272,7 @@ .show() mBackAppTime = System.currentTimeMillis() } else { - closeAll() + moveTaskToBack(true) } } @@ -257,6 +285,13 @@ BaseEvent.REQUEST_CAR_INFO -> { Handler(Looper.getMainLooper()).post { toast("收到显示屏信息") + } + } + BaseEvent.ERROR_INFO -> { + try { + mainFragment.refresh() + }catch (e:Exception){ + } } } @@ -284,12 +319,18 @@ var bean = gson.fromJson<VersionBean>(it, VersionBean::class.java) if (bean.data.version != "" && bean.data.version != Utils.getAppVersion(this)) { if (bean.data.mandatory == 0) { - var pop = DialogUtil.getSlabDelAndSurePopWindow(this, "有新版本是否更新", {}) { - DownloadUtil(this).downloadAPK(bean.data.url, "ok出行车载端") - } + var pop = + DialogUtil.getSlabDelAndSurePopWindow(this, "确定", "取消", "有新版本是否更新", {}) { + DownloadUtil(this).downloadAPK(bean.data.url, "ok出行车载端") + } pop.showCenter(window.decorView) } else { - var pop = DialogUtil.getSlabDelAndSurePopWindow(this, "版本已过时,是否强制升级?", {}) { + var pop = DialogUtil.getSlabDelAndSurePopWindow( + this, + "确定", + "取消", + "版本已过时,是否强制升级?", + {}) { DownloadUtil(this).downloadAPK(bean.data.url, "ok出行车载端") toast("后台开始下载,请等待") } @@ -301,4 +342,39 @@ } } } + + + private fun callLogin(ok: () -> Unit) { + var jobNum = CacheKey.getKeyStr("jobNum") + 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) { + 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() + } + } else { + ok() + } + } } \ No newline at end of file -- Gitblit v1.7.1