fix vip cancel bug and add new interface of trafficCrossRoad event

This commit is contained in:
zhongchao
2021-11-25 21:27:17 +08:00
parent 80efeb0bf2
commit 96cfc293fe
7 changed files with 87 additions and 20 deletions

View File

@@ -62,6 +62,50 @@ object CallTrafficLightListenerManager {
}
}
/**
* 添加监听
* @param tag 标记,用来注销监听使用
* @param listener 监听回调
*/
fun registerEnterCrossRoadListener(
@Nullable tag: String,
@Nullable listener: IMoGoTrafficLightListener
) {
if (M_TRAFFIC_LIGHT_LISTENER.containsKey(tag)) {
LogUtils.eTag(TAG, "Tag:$tag already exists,please use other tag")
return
}
M_TRAFFIC_LIGHT_LISTENER[tag] = listener
}
/**
* 删除监听
* @param tag 标记,用来注销监听使用
*/
fun unRegisterEnterCrossRoadListener(@Nullable tag: String) {
if (!M_TRAFFIC_LIGHT_LISTENER.containsKey(tag)) {
LogUtils.eTag(TAG, "Tag:$tag not exists")
return
}
M_TRAFFIC_LIGHT_LISTENER.remove(tag)
}
/**
* 删除监听
* @param listener 要删除的监听对象
*/
fun unRegisterEnterCrossRoadListener(@Nullable listener: IMoGoTrafficLightListener) {
if (!M_TRAFFIC_LIGHT_LISTENER.containsValue(listener)) {
LogUtils.eTag(TAG, "listener:$listener not exists")
return
}
M_TRAFFIC_LIGHT_LISTENER.forEach {
if (it.value == listener) {
M_TRAFFIC_LIGHT_LISTENER.remove(it.key)
}
}
}
fun invokeTrafficLightStatus(trafficLightResult: TrafficLightResult) {
this.trafficLightResult = trafficLightResult
M_TRAFFIC_LIGHT_LISTENER.forEach {
@@ -72,6 +116,13 @@ object CallTrafficLightListenerManager {
}
}
fun invokeEnterCrossRoad(){
M_TRAFFIC_LIGHT_LISTENER.forEach {
val listener = it.value
listener.onEnterCrossRoad()
}
}
fun resetTrafficLightData() {
trafficLightResult = null
}