diff --git a/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/vip/VipCarManager.kt b/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/vip/VipCarManager.kt index aaf98f4403..54a99c2ed2 100644 --- a/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/vip/VipCarManager.kt +++ b/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/vip/VipCarManager.kt @@ -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, 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) } diff --git a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/vip/IMoGoVipSetListener.kt b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/vip/IMoGoVipSetListener.kt new file mode 100644 index 0000000000..973a73009a --- /dev/null +++ b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/vip/IMoGoVipSetListener.kt @@ -0,0 +1,9 @@ +package com.mogo.eagle.core.function.api.vip + +interface IMoGoVipSetListener { + + /** + * 设置Vip状态 + */ + fun onVipSet(status:Boolean) +} \ No newline at end of file diff --git a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/trafficlight/CallTrafficLightListenerManager.kt b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/trafficlight/CallTrafficLightListenerManager.kt index 23fdee3b58..065585e496 100644 --- a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/trafficlight/CallTrafficLightListenerManager.kt +++ b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/trafficlight/CallTrafficLightListenerManager.kt @@ -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 = ConcurrentHashMap() @@ -47,7 +47,7 @@ object CallTrafficLightListenerManager { } /** - * 删除自动驾驶按钮选中监听 + * 删除监听 * @param listener 要删除的监听对象 */ fun unRegisterTrafficLightListener(@Nullable listener: IMoGoTrafficLightListener) { diff --git a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/vip/CallVipSetListenerManager.kt b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/vip/CallVipSetListenerManager.kt new file mode 100644 index 0000000000..e3632f3ec6 --- /dev/null +++ b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/vip/CallVipSetListenerManager.kt @@ -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 = + 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) + } + } + +} \ No newline at end of file