@@ -4,6 +4,7 @@ import androidx.annotation.Nullable
|
||||
import com.mogo.eagle.core.data.obu.ObuStatusInfo
|
||||
import com.mogo.eagle.core.function.api.obu.IMoGoObuStatusListener
|
||||
import com.mogo.eagle.core.function.call.base.CallerBase
|
||||
import com.mogo.eagle.core.utilcode.util.GsonUtils
|
||||
import com.mogo.eagle.core.utilcode.util.LogUtils
|
||||
|
||||
/**
|
||||
@@ -16,15 +17,23 @@ object CallerObuListenerManager : CallerBase() {
|
||||
|
||||
// 存储最后一次回调的数据,当有新当位置注册了监听将此数据回调过去,防止有些模块注册顺序问题导致无法获取最新状态
|
||||
private var mObuStatusInfo: ObuStatusInfo = ObuStatusInfo()
|
||||
|
||||
// 存储所有注册了监听的对象,invokeXXXX进行遍历回调,将信息同步
|
||||
private val mObuStatusListeners: HashMap<String, IMoGoObuStatusListener> = HashMap()
|
||||
|
||||
/**
|
||||
* 查询OBU状态
|
||||
*/
|
||||
fun getObuStatusInfo(): String {
|
||||
return GsonUtils.toJson(mObuStatusInfo)
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加自动驾驶按钮选中监听
|
||||
* @param tag 标记,用来注销监听使用
|
||||
* @param listener 监听回调
|
||||
*/
|
||||
fun addCheckAutoPilotBtnListener(
|
||||
fun addListener(
|
||||
@Nullable tag: String,
|
||||
@Nullable listener: IMoGoObuStatusListener
|
||||
) {
|
||||
@@ -33,18 +42,30 @@ object CallerObuListenerManager : CallerBase() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除自动驾驶按钮选中监听
|
||||
* 删除 监听
|
||||
* @param tag 标记,用来注销监听使用
|
||||
*/
|
||||
fun removeCheckAutoPilotBtnListener(@Nullable tag: String) {
|
||||
fun removeListener(@Nullable tag: String) {
|
||||
mObuStatusListeners.remove(tag)
|
||||
}
|
||||
|
||||
/**
|
||||
* 触发自动驾驶按钮选中监听
|
||||
* @param isChecked 选中状态
|
||||
* 删除自动驾驶按钮选中监听
|
||||
* @param listener 要删除的监听对象
|
||||
*/
|
||||
fun invokeCheckAutoPilotBtnListener(obuStatusInfo: ObuStatusInfo) {
|
||||
fun removeListener(@Nullable listener: IMoGoObuStatusListener) {
|
||||
mObuStatusListeners.forEach {
|
||||
if (it.value == listener) {
|
||||
mObuStatusListeners.remove(it.key)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 触发自动驾驶按钮选中监听
|
||||
* @param obuStatusInfo 选中状态
|
||||
*/
|
||||
fun invokeListener(obuStatusInfo: ObuStatusInfo) {
|
||||
LogUtils.dTag(TAG, "isChecked:$obuStatusInfo")
|
||||
mObuStatusInfo = obuStatusInfo
|
||||
mObuStatusListeners.forEach {
|
||||
|
||||
Reference in New Issue
Block a user