[2.13.2]消息盒子全程点击事件分发给业务侧进行后续处理
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
package com.mogo.eagle.core.function.call.msgbox
|
||||
|
||||
import androidx.annotation.Nullable
|
||||
import com.mogo.eagle.core.function.api.msgbox.IMsgBoxEventListener
|
||||
import com.mogo.eagle.core.function.call.base.CallerBase
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
/**
|
||||
* @author XuXinChao
|
||||
* @date 2023/1/16
|
||||
* 消息盒子事件监听管理
|
||||
*/
|
||||
object CallerMsgBoxEventListenerManager: CallerBase() {
|
||||
|
||||
private val statusListeners: ConcurrentHashMap<String, IMsgBoxEventListener> =
|
||||
ConcurrentHashMap()
|
||||
|
||||
/**
|
||||
* 添加数据监听
|
||||
* @param tag 标记,用来注销监听使用
|
||||
* @param listener 监听回调
|
||||
*/
|
||||
fun addListener(@Nullable tag: String,@Nullable listener: IMsgBoxEventListener){
|
||||
if (statusListeners.containsKey(tag)) {
|
||||
return
|
||||
}
|
||||
statusListeners[tag] = listener
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除状态监听
|
||||
* @param tag 标记,用来注销监听使用
|
||||
*/
|
||||
fun removeListener(@Nullable tag: String) {
|
||||
if (!statusListeners.containsKey(tag)) {
|
||||
return
|
||||
}
|
||||
statusListeners.remove(tag)
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除状态监听
|
||||
* @param listener 要删除的监听对象
|
||||
*/
|
||||
fun removeListener(@Nullable listener: IMsgBoxEventListener){
|
||||
if (!statusListeners.containsValue(listener)) {
|
||||
return
|
||||
}
|
||||
var tag = ""
|
||||
statusListeners.forEach {
|
||||
if (it.value == listener) {
|
||||
tag = it.key
|
||||
statusListeners.remove(it.key)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 触发监听
|
||||
*/
|
||||
fun invokeListener(){
|
||||
statusListeners.forEach {
|
||||
val tag = it.key
|
||||
val listener = it.value
|
||||
listener.onSummaryClickEvent()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user