fix ui bug and add log

This commit is contained in:
zhongchao
2021-11-10 20:05:30 +08:00
parent 7e306c6715
commit 624abbe706
7 changed files with 40 additions and 17 deletions

View File

@@ -12,6 +12,7 @@ import com.mogo.eagle.core.function.api.trafficlight.IMoGoTrafficLightListener
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager
import com.mogo.eagle.core.function.call.trafficlight.CallTrafficLightListenerManager
import com.mogo.eagle.core.function.v2x.trafficlight.core.MogoTrafficLightManager
import com.mogo.eagle.core.utilcode.util.SPUtils
import com.mogo.map.navi.IMogoCarLocationChangedListener2
import com.mogo.module.common.MogoApisHandler
import com.mogo.module.common.enums.EventTypeEnum
@@ -37,9 +38,23 @@ class VipCarManager : IMogoOnMessageListener<VipMessage>, IMoGoTrafficLightListe
fun initServer(context: Context) {
mContext = context
MogoApisHandler.getInstance().apis.registerCenterApi.registerCarLocationChangedListener(TAG, this)
MogoApisHandler.getInstance().apis.getSocketManagerApi(context)
MogoApisHandler.getInstance()
.apis.registerCenterApi.registerCarLocationChangedListener(TAG, this)
MogoApisHandler.getInstance()
.apis.getSocketManagerApi(context)
.registerOnMessageListener(401025, this)
val vipSetTime = SPUtils.getInstance().getLong("vip")
if (vipSetTime == -1L) {
return
}
//todo 后续改成接口调用查询,防止清除缓存造成状态不统一
if (vipSetTime > 0 && System.currentTimeMillis() - vipSetTime < 0) { //未超时需要设置VIP
CallerHmiManager.vipIdentification(true)
CallTrafficLightListenerManager.registerTrafficLightListener(TAG, this)
} else {
SPUtils.getInstance().remove("vip") //超时
}
}
override fun target(): Class<VipMessage> {
@@ -47,13 +62,16 @@ class VipCarManager : IMogoOnMessageListener<VipMessage>, IMoGoTrafficLightListe
}
override fun onMsgReceived(vipMessage: VipMessage?) {
Logger.d(TAG, "onMsgReceived vipMessage : ${vipMessage.toString()}")
vipMessage?.let {
when (it.vipType) {
0 -> {
0 -> { //取消VIP
SPUtils.getInstance().remove("vip")
CallerHmiManager.vipIdentification(false)
CallTrafficLightListenerManager.unRegisterTrafficLightListener(TAG)
}
1 -> {
1 -> { //设置VIP
SPUtils.getInstance().put("vip", vipMessage.timeOut)
CallerHmiManager.vipIdentification(true)
CallTrafficLightListenerManager.registerTrafficLightListener(TAG, this)
}
@@ -67,7 +85,7 @@ class VipCarManager : IMogoOnMessageListener<VipMessage>, IMoGoTrafficLightListe
//如果上次结果和本次灯态结果变化比较大则已变灯控制HMI展示弹窗
if ((result!!.laneList.mid.remain - trafficLightResult.laneList.mid.remain) > 3) {
CallerHmiManager.showWarningV2X(EventTypeEnum.TYPE_VIP_IDENTIFICATION.poiType.toInt(),
"",
EventTypeEnum.TYPE_VIP_IDENTIFICATION.content,
EventTypeEnum.TYPE_VIP_IDENTIFICATION.tts,
EventTypeEnum.TYPE_VIP_IDENTIFICATION.poiType,
object : IMoGoWarningStatusListener {