完成了自动驾驶按钮的点击触发逻辑抽离

Signed-off-by: 董宏宇 <martindhy@gmail.com>
This commit is contained in:
董宏宇
2021-09-23 10:57:34 +08:00
parent 808e772cce
commit d80348b32f
15 changed files with 210 additions and 186 deletions

View File

@@ -0,0 +1,56 @@
package com.mogo.eagle.core.function.call.hmi
import androidx.annotation.Nullable
import com.mogo.eagle.core.function.api.hmi.autopilot.IMoGoCheckAutoPilotBtnListener
import com.mogo.eagle.core.function.call.base.CallerBase
import com.mogo.eagle.core.utilcode.util.LogUtils
/**
* @author xiaoyuzhou
* @date 2021/9/23 10:22 上午
* HMI 视图上的监听管理
*/
object CallerHmiListenerManager : CallerBase() {
private val TAG = "CallerHmiListenerManager"
private val checkAutoPilotBtnListeners: HashMap<String, IMoGoCheckAutoPilotBtnListener> =
HashMap()
/**
* 添加自动驾驶按钮选中监听
* @param tag 标记,用来注销监听使用
* @param listener 监听回调
*/
fun addCheckAutoPilotBtnListener(
@Nullable tag: String,
@Nullable listener: IMoGoCheckAutoPilotBtnListener
) {
checkAutoPilotBtnListeners[tag] = listener
}
/**
* 删除自动驾驶按钮选中监听
* @param tag 标记,用来注销监听使用
*/
fun removeCheckAutoPilotBtnListener(@Nullable tag: String) {
checkAutoPilotBtnListeners.remove(tag)
}
/**
* 触发自动驾驶按钮选中监听
* @param isChecked 选中状态
*/
fun invokeCheckAutoPilotBtnListener(isChecked: Boolean) {
LogUtils.dTag(TAG, "isChecked:$isChecked")
checkAutoPilotBtnListeners.forEach {
val tag = it.key
val listener = it.value
LogUtils.dTag(TAG, "tag:$tag listener:$listener")
listener.onCheck(isChecked)
}
}
}

View File

@@ -2,6 +2,7 @@ package com.mogo.eagle.core.function.call.hmi
import com.mogo.eagle.core.data.constants.MogoServicePaths
import com.mogo.eagle.core.data.enums.WarningDirectionEnum
import com.mogo.eagle.core.function.api.hmi.autopilot.IMoGoCheckAutoPilotBtnListener
import com.mogo.eagle.core.function.api.hmi.warning.IMoGoWaringProvider
import com.mogo.eagle.core.function.api.hmi.warning.WarningStatusListener
import com.mogo.eagle.core.function.call.base.CallerBase