add new func of logcatch
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
package com.mogo.eagle.core.function.call.devatools
|
||||
|
||||
import androidx.annotation.Nullable
|
||||
import com.mogo.eagle.core.function.api.devatools.IMoGoDevaToolsListener
|
||||
import com.mogo.eagle.core.utilcode.util.LogUtils
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
object CallDevaToolsListenerManager {
|
||||
|
||||
private const val TAG = "CallDevaToolsListenerManager"
|
||||
|
||||
private val M_DEVA_TOOLS_LISTENER: ConcurrentHashMap<String, IMoGoDevaToolsListener> =
|
||||
ConcurrentHashMap()
|
||||
|
||||
/**
|
||||
* 添加监听
|
||||
* @param tag 标记,用来注销监听使用
|
||||
* @param listener 监听回调
|
||||
*/
|
||||
fun registerDevaToolsLogCatchListener(
|
||||
@Nullable tag: String,
|
||||
@Nullable listener: IMoGoDevaToolsListener
|
||||
) {
|
||||
if (M_DEVA_TOOLS_LISTENER.containsKey(tag)) {
|
||||
LogUtils.eTag(TAG, "Tag:$tag already exists,please use other tag")
|
||||
return
|
||||
}
|
||||
M_DEVA_TOOLS_LISTENER[tag] = listener
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除监听
|
||||
* @param tag 标记,用来注销监听使用
|
||||
*/
|
||||
fun unRegisterDevaToolsLogCatchListener(@Nullable tag: String) {
|
||||
if (!M_DEVA_TOOLS_LISTENER.containsKey(tag)) {
|
||||
LogUtils.eTag(TAG, "Tag:$tag not exists")
|
||||
return
|
||||
}
|
||||
M_DEVA_TOOLS_LISTENER.remove(tag)
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除监听
|
||||
* @param listener 要删除的监听对象
|
||||
*/
|
||||
fun unRegisterDevaToolsLogCatchListener(@Nullable listener: IMoGoDevaToolsListener) {
|
||||
if (!M_DEVA_TOOLS_LISTENER.containsValue(listener)) {
|
||||
LogUtils.eTag(TAG, "listener:$listener not exists")
|
||||
return
|
||||
}
|
||||
M_DEVA_TOOLS_LISTENER.forEach {
|
||||
if (it.value == listener) {
|
||||
M_DEVA_TOOLS_LISTENER.remove(it.key)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun invokeDevaToolsLogCatch() {
|
||||
M_DEVA_TOOLS_LISTENER.forEach {
|
||||
val listener = it.value
|
||||
listener.onLogCatchClose()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user