fix bug of vip listener

This commit is contained in:
zhongchao
2021-11-23 15:00:33 +08:00
parent ae16be40ab
commit 5eb1565051
4 changed files with 85 additions and 2 deletions

View File

@@ -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) {

View File

@@ -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)
}
}
}