fix bug of vip listener
This commit is contained in:
@@ -15,6 +15,7 @@ import com.mogo.eagle.core.function.api.hmi.warning.IMoGoWarningStatusListener
|
||||
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.call.vip.CallVipSetListenerManager
|
||||
import com.mogo.eagle.core.function.v2x.trafficlight.core.MogoTrafficLightManager
|
||||
import com.mogo.eagle.core.function.v2x.vip.network.VipNetWorkModel
|
||||
import com.mogo.map.navi.IMogoCarLocationChangedListener2
|
||||
@@ -152,12 +153,14 @@ class VipCarManager : IMogoOnMessageListener<VipMessage>, IMoGoTrafficLightListe
|
||||
private fun setVip() {
|
||||
vip = true
|
||||
CallerHmiManager.vipIdentification(true)
|
||||
CallVipSetListenerManager.invokeVipSetStatus(true)
|
||||
CallTrafficLightListenerManager.registerTrafficLightListener(TAG, this)
|
||||
}
|
||||
|
||||
private fun cancelVip() {
|
||||
vip = false
|
||||
CallerHmiManager.vipIdentification(false)
|
||||
CallVipSetListenerManager.invokeVipSetStatus(false)
|
||||
CallTrafficLightListenerManager.unRegisterTrafficLightListener(TAG)
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.mogo.eagle.core.function.api.vip
|
||||
|
||||
interface IMoGoVipSetListener {
|
||||
|
||||
/**
|
||||
* 设置Vip状态
|
||||
*/
|
||||
fun onVipSet(status:Boolean)
|
||||
}
|
||||
@@ -8,7 +8,7 @@ import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
object CallTrafficLightListenerManager {
|
||||
|
||||
private val TAG = "CallTrafficLightListenerManager"
|
||||
private const val TAG = "CallTrafficLightListenerManager"
|
||||
|
||||
private val M_TRAFFIC_LIGHT_LISTENER: ConcurrentHashMap<String, IMoGoTrafficLightListener> =
|
||||
ConcurrentHashMap()
|
||||
@@ -47,7 +47,7 @@ object CallTrafficLightListenerManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除自动驾驶按钮选中监听
|
||||
* 删除监听
|
||||
* @param listener 要删除的监听对象
|
||||
*/
|
||||
fun unRegisterTrafficLightListener(@Nullable listener: IMoGoTrafficLightListener) {
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.mogo.eagle.core.function.call.vip
|
||||
|
||||
import androidx.annotation.Nullable
|
||||
import com.mogo.eagle.core.function.api.vip.IMoGoVipSetListener
|
||||
import com.mogo.eagle.core.utilcode.util.LogUtils
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
object CallVipSetListenerManager {
|
||||
|
||||
private const val TAG = "CallVipSetListenerManager"
|
||||
|
||||
private val M_VIP_SET_LISTENER: ConcurrentHashMap<String, IMoGoVipSetListener> =
|
||||
ConcurrentHashMap()
|
||||
|
||||
private var vipSet: Boolean = false
|
||||
|
||||
/**
|
||||
* 添加监听
|
||||
* @param tag 标记,用来注销监听使用
|
||||
* @param listener 监听回调
|
||||
*/
|
||||
fun registerVipSetListener(
|
||||
@Nullable tag: String,
|
||||
@Nullable listener: IMoGoVipSetListener
|
||||
) {
|
||||
if (M_VIP_SET_LISTENER.containsKey(tag)) {
|
||||
LogUtils.eTag(TAG, "Tag:$tag already exists,please use other tag")
|
||||
return
|
||||
}
|
||||
listener.onVipSet(vipSet)
|
||||
M_VIP_SET_LISTENER[tag] = listener
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除监听
|
||||
* @param tag 标记,用来注销监听使用
|
||||
*/
|
||||
fun unRegisterVipSetListener(@Nullable tag: String) {
|
||||
if (!M_VIP_SET_LISTENER.containsKey(tag)) {
|
||||
LogUtils.eTag(TAG, "Tag:$tag not exists")
|
||||
return
|
||||
}
|
||||
M_VIP_SET_LISTENER.remove(tag)
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除监听
|
||||
* @param listener 要删除的监听对象
|
||||
*/
|
||||
fun unRegisterVipSetListener(@Nullable listener: IMoGoVipSetListener) {
|
||||
if (!M_VIP_SET_LISTENER.containsValue(listener)) {
|
||||
LogUtils.eTag(TAG, "listener:$listener not exists")
|
||||
return
|
||||
}
|
||||
M_VIP_SET_LISTENER.forEach {
|
||||
if (it.value == listener) {
|
||||
M_VIP_SET_LISTENER.remove(it.key)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun invokeVipSetStatus(vipStatus: Boolean) {
|
||||
this.vipSet = vipStatus
|
||||
M_VIP_SET_LISTENER.forEach {
|
||||
val tag = it.key
|
||||
val listener = it.value
|
||||
listener.onVipSet(vipStatus)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user