[Add]DebugSettingView增加动态控制日志输出
Signed-off-by: donghongyu <donghongyu@zhidaoauto.com>
This commit is contained in:
@@ -4,7 +4,7 @@ import com.mogo.eagle.core.data.autopilot.AutopilotControlParameters
|
||||
import com.mogo.eagle.core.data.constants.MogoServicePaths
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotProvider
|
||||
import com.mogo.eagle.core.function.call.base.CallerBase
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
|
||||
import com.mogo.eagle.core.utilcode.util.LogUtils
|
||||
|
||||
/**
|
||||
*@author xiaoyuzhou
|
||||
@@ -27,7 +27,7 @@ object CallerAutoPilotManager {
|
||||
*/
|
||||
fun startAutoPilot(controlParameters: AutopilotControlParameters?) {
|
||||
if (controlParameters == null) {
|
||||
Logger.e(TAG, "自动驾驶控制参数异常,请检查参数信息")
|
||||
//LogUtils.eTag(TAG, "自动驾驶控制参数异常,请检查参数信息")
|
||||
return
|
||||
}
|
||||
providerApi.startAutoPilot(controlParameters)
|
||||
@@ -55,5 +55,12 @@ object CallerAutoPilotManager {
|
||||
providerApi.recordPackage()
|
||||
}
|
||||
|
||||
fun setEnableLog(isEnableLog: Boolean) {
|
||||
providerApi.setEnableLog(isEnableLog)
|
||||
}
|
||||
|
||||
fun setIsWriteLog(isWriteLog: Boolean) {
|
||||
providerApi.setIsWriteLog(isWriteLog)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
|
||||
import com.mogo.eagle.core.function.call.base.CallerBase
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
|
||||
import com.mogo.eagle.core.utilcode.util.GsonUtils
|
||||
import com.mogo.eagle.core.utilcode.util.LogUtils
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
/**
|
||||
@@ -49,7 +50,7 @@ object CallerAutoPilotStatusListenerManager : CallerBase() {
|
||||
@Nullable listener: IMoGoAutopilotStatusListener
|
||||
) {
|
||||
if (M_AUTOPILOT_STATUS_LISTENERS.containsKey(tag)) {
|
||||
Logger.e(TAG, "Tag:$tag already exists,please use other tag")
|
||||
LogUtils.eTag(TAG, "Tag:$tag already exists,please use other tag")
|
||||
return
|
||||
}
|
||||
M_AUTOPILOT_STATUS_LISTENERS[tag] = listener
|
||||
@@ -62,7 +63,7 @@ object CallerAutoPilotStatusListenerManager : CallerBase() {
|
||||
*/
|
||||
fun removeListener(@Nullable tag: String) {
|
||||
if (!M_AUTOPILOT_STATUS_LISTENERS.containsKey(tag)) {
|
||||
Logger.e(TAG, "Tag:$tag not exists")
|
||||
LogUtils.eTag(TAG, "Tag:$tag not exists")
|
||||
return
|
||||
}
|
||||
M_AUTOPILOT_STATUS_LISTENERS.remove(tag)
|
||||
@@ -85,7 +86,7 @@ object CallerAutoPilotStatusListenerManager : CallerBase() {
|
||||
*/
|
||||
@Synchronized
|
||||
fun invokeAutoPilotStatus() {
|
||||
//Logger.d(TAG, "$mAutopilotStatusInfo")
|
||||
//LogUtils.dTag(TAG, "$mAutopilotStatusInfo")
|
||||
invokeAutoPilotStatus(mAutopilotStatusInfo)
|
||||
}
|
||||
|
||||
@@ -95,12 +96,12 @@ object CallerAutoPilotStatusListenerManager : CallerBase() {
|
||||
*/
|
||||
@Synchronized
|
||||
fun invokeAutoPilotStatus(autopilotStatusInfo: AutopilotStatusInfo) {
|
||||
//Logger.d(TAG, "$autopilotStatusInfo")
|
||||
//LogUtils.dTag(TAG, "$autopilotStatusInfo")
|
||||
mAutopilotStatusInfo = autopilotStatusInfo
|
||||
M_AUTOPILOT_STATUS_LISTENERS.forEach {
|
||||
val tag = it.key
|
||||
val listener = it.value
|
||||
//Logger.d(TAG, "tag:$tag listener:$listener")
|
||||
//LogUtils.dTag(TAG, "tag:$tag listener:$listener")
|
||||
listener.onAutopilotStatusResponse(mAutopilotStatusInfo)
|
||||
}
|
||||
}
|
||||
@@ -111,11 +112,11 @@ object CallerAutoPilotStatusListenerManager : CallerBase() {
|
||||
*/
|
||||
@Synchronized
|
||||
fun invokeArriveAtStation(autopilotStationInfo: AutopilotStationInfo) {
|
||||
//Logger.d(TAG, "$autopilotStationInfo")
|
||||
//LogUtils.dTag(TAG, "$autopilotStationInfo")
|
||||
M_AUTOPILOT_STATUS_LISTENERS.forEach {
|
||||
val tag = it.key
|
||||
val listener = it.value
|
||||
//Logger.d(TAG, "tag:$tag listener:$listener")
|
||||
//LogUtils.dTag(TAG, "tag:$tag listener:$listener")
|
||||
listener.onAutopilotArriveAtStation(autopilotStationInfo)
|
||||
}
|
||||
}
|
||||
@@ -125,11 +126,11 @@ object CallerAutoPilotStatusListenerManager : CallerBase() {
|
||||
*/
|
||||
@Synchronized
|
||||
fun invokeAutopilotSNRequest() {
|
||||
//Logger.d(TAG, "")
|
||||
//LogUtils.dTag(TAG, "")
|
||||
M_AUTOPILOT_STATUS_LISTENERS.forEach {
|
||||
val tag = it.key
|
||||
val listener = it.value
|
||||
//Logger.d(TAG, "tag:$tag listener:$listener")
|
||||
//LogUtils.dTag(TAG, "tag:$tag listener:$listener")
|
||||
listener.onAutopilotSNRequest()
|
||||
}
|
||||
}
|
||||
@@ -139,11 +140,11 @@ object CallerAutoPilotStatusListenerManager : CallerBase() {
|
||||
*/
|
||||
@Synchronized
|
||||
fun invokeAutopilotGuardian(guardianInfo: AutopilotGuardianStatusInfo?) {
|
||||
//Logger.d(TAG, "$guardianInfo")
|
||||
//LogUtils.dTag(TAG, "$guardianInfo")
|
||||
M_AUTOPILOT_STATUS_LISTENERS.forEach {
|
||||
val tag = it.key
|
||||
val listener = it.value
|
||||
//Logger.d(TAG, "tag:$tag listener:$listener")
|
||||
//LogUtils.dTag(TAG, "tag:$tag listener:$listener")
|
||||
listener.onAutopilotGuardian(guardianInfo)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import androidx.annotation.Nullable
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotCarStateInfo
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotCarStateListener
|
||||
import com.mogo.eagle.core.function.call.base.CallerBase
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
|
||||
import com.mogo.eagle.core.utilcode.util.LogUtils
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
/**
|
||||
@@ -30,7 +30,7 @@ object CallerAutopilotCarStatusListenerManager : CallerBase() {
|
||||
@Nullable listener: IMoGoAutopilotCarStateListener
|
||||
) {
|
||||
if (M_AUTOPILOT_STATUS_LISTENERS.containsKey(tag)) {
|
||||
Logger.e(TAG, "Tag:$tag already exists,please use other tag")
|
||||
LogUtils.eTag(TAG, "Tag:$tag already exists,please use other tag")
|
||||
return
|
||||
}
|
||||
M_AUTOPILOT_STATUS_LISTENERS[tag] = listener
|
||||
@@ -42,7 +42,7 @@ object CallerAutopilotCarStatusListenerManager : CallerBase() {
|
||||
*/
|
||||
fun removeListener(@Nullable tag: String) {
|
||||
if (!M_AUTOPILOT_STATUS_LISTENERS.containsKey(tag)) {
|
||||
Logger.e(TAG, "Tag:$tag not exists")
|
||||
LogUtils.eTag(TAG, "Tag:$tag not exists")
|
||||
return
|
||||
}
|
||||
M_AUTOPILOT_STATUS_LISTENERS.remove(tag)
|
||||
@@ -66,11 +66,11 @@ object CallerAutopilotCarStatusListenerManager : CallerBase() {
|
||||
*/
|
||||
@Synchronized
|
||||
fun invokeAutopilotCarStateData(autoPilotCarStateInfo: AutopilotCarStateInfo?) {
|
||||
//Logger.d(TAG, "$autoPilotCarStateInfo")
|
||||
//LogUtils.dTag(TAG, "$autoPilotCarStateInfo")
|
||||
M_AUTOPILOT_STATUS_LISTENERS.forEach {
|
||||
val tag = it.key
|
||||
val listener = it.value
|
||||
//Logger.d(TAG, "tag:$tag listener:$listener")
|
||||
//LogUtils.dTag(TAG, "tag:$tag listener:$listener")
|
||||
listener.onAutopilotCarStateData(autoPilotCarStateInfo)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.mogo.eagle.core.data.autopilot.AutopilotWarnMessage
|
||||
import com.mogo.eagle.core.data.traffic.TrafficData
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotIdentifyListener
|
||||
import com.mogo.eagle.core.function.call.base.CallerBase
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
|
||||
import com.mogo.eagle.core.utilcode.util.LogUtils
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
/**
|
||||
@@ -30,7 +30,7 @@ object CallerAutopilotIdentifyListenerManager : CallerBase() {
|
||||
@Nullable listener: IMoGoAutopilotIdentifyListener
|
||||
) {
|
||||
if (M_AUTOPILOT_IDENTIFY_LISTENERS.containsKey(tag)) {
|
||||
Logger.e(TAG, "Tag:$tag already exists,please use other tag")
|
||||
LogUtils.eTag(TAG, "Tag:$tag already exists,please use other tag")
|
||||
return
|
||||
}
|
||||
M_AUTOPILOT_IDENTIFY_LISTENERS[tag] = listener
|
||||
@@ -42,7 +42,7 @@ object CallerAutopilotIdentifyListenerManager : CallerBase() {
|
||||
*/
|
||||
fun removeListener(@Nullable tag: String) {
|
||||
if (!M_AUTOPILOT_IDENTIFY_LISTENERS.containsKey(tag)) {
|
||||
Logger.e(TAG, "Tag:$tag not exists")
|
||||
LogUtils.eTag(TAG, "Tag:$tag not exists")
|
||||
return
|
||||
}
|
||||
M_AUTOPILOT_IDENTIFY_LISTENERS.remove(tag)
|
||||
@@ -65,11 +65,11 @@ object CallerAutopilotIdentifyListenerManager : CallerBase() {
|
||||
*/
|
||||
@Synchronized
|
||||
fun invokeAutopilotIdentifyDataUpdate(trafficData: ArrayList<TrafficData>?) {
|
||||
//Logger.d(TAG, "$trafficData")
|
||||
//LogUtils.dTag(TAG, "$trafficData")
|
||||
M_AUTOPILOT_IDENTIFY_LISTENERS.forEach {
|
||||
val tag = it.key
|
||||
val listener = it.value
|
||||
//Logger.d(TAG, "tag:$tag listener:$listener")
|
||||
//LogUtils.dTag(TAG, "tag:$tag listener:$listener")
|
||||
listener.onAutopilotIdentifyDataUpdate(trafficData)
|
||||
}
|
||||
}
|
||||
@@ -79,11 +79,11 @@ object CallerAutopilotIdentifyListenerManager : CallerBase() {
|
||||
*/
|
||||
@Synchronized
|
||||
fun invokeAutopilotWarnMessage(autopilotWarnMessage: AutopilotWarnMessage?) {
|
||||
//Logger.d(TAG, "$autopilotWarnMessage")
|
||||
//LogUtils.dTag(TAG, "$autopilotWarnMessage")
|
||||
M_AUTOPILOT_IDENTIFY_LISTENERS.forEach {
|
||||
val tag = it.key
|
||||
val listener = it.value
|
||||
//Logger.d(TAG, "tag:$tag listener:$listener")
|
||||
//LogUtils.dTag(TAG, "tag:$tag listener:$listener")
|
||||
listener.onAutopilotWarnMessage(autopilotWarnMessage)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.mogo.eagle.core.data.autopilot.ADASTrajectoryInfo
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotRouteInfo
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotPlanningListener
|
||||
import com.mogo.eagle.core.function.call.base.CallerBase
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
|
||||
import com.mogo.eagle.core.utilcode.util.LogUtils
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
/**
|
||||
@@ -31,7 +31,7 @@ object CallerAutopilotPlanningListenerManager : CallerBase() {
|
||||
@Nullable listener: IMoGoAutopilotPlanningListener
|
||||
) {
|
||||
if (M_AUTOPILOT_PLANNING_LISTENER.containsKey(tag)) {
|
||||
Logger.e(TAG, "Tag:$tag already exists,please use other tag")
|
||||
LogUtils.eTag(TAG, "Tag:$tag already exists,please use other tag")
|
||||
return
|
||||
}
|
||||
M_AUTOPILOT_PLANNING_LISTENER[tag] = listener
|
||||
@@ -43,7 +43,7 @@ object CallerAutopilotPlanningListenerManager : CallerBase() {
|
||||
*/
|
||||
fun removeListener(@Nullable tag: String) {
|
||||
if (!M_AUTOPILOT_PLANNING_LISTENER.containsKey(tag)) {
|
||||
Logger.e(TAG, "Tag:$tag not exists")
|
||||
LogUtils.eTag(TAG, "Tag:$tag not exists")
|
||||
return
|
||||
}
|
||||
M_AUTOPILOT_PLANNING_LISTENER.remove(tag)
|
||||
@@ -67,11 +67,11 @@ object CallerAutopilotPlanningListenerManager : CallerBase() {
|
||||
*/
|
||||
@Synchronized
|
||||
fun invokeAutopilotTrajectory(trajectoryInfo: ArrayList<ADASTrajectoryInfo>) {
|
||||
//Logger.d(TAG, "$trajectoryInfo")
|
||||
//LogUtils.dTag(TAG, "$trajectoryInfo")
|
||||
M_AUTOPILOT_PLANNING_LISTENER.forEach {
|
||||
val tag = it.key
|
||||
val listener = it.value
|
||||
//Logger.d(TAG, "tag:$tag listener:$listener")
|
||||
//LogUtils.dTag(TAG, "tag:$tag listener:$listener")
|
||||
listener.onAutopilotTrajectory(trajectoryInfo)
|
||||
}
|
||||
}
|
||||
@@ -82,11 +82,11 @@ object CallerAutopilotPlanningListenerManager : CallerBase() {
|
||||
*/
|
||||
@Synchronized
|
||||
fun invokeAutopilotRotting(routeList: AutopilotRouteInfo) {
|
||||
//Logger.d(TAG, "$routeList")
|
||||
//LogUtils.dTag(TAG, "$routeList")
|
||||
M_AUTOPILOT_PLANNING_LISTENER.forEach {
|
||||
val tag = it.key
|
||||
val listener = it.value
|
||||
//Logger.d(TAG, "tag:$tag listener:$listener")
|
||||
//LogUtils.dTag(TAG, "tag:$tag listener:$listener")
|
||||
listener.onAutopilotRotting(routeList)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,8 @@ object CallerHmiListenerManager : CallerBase() {
|
||||
private var mIsChecked: Boolean = false
|
||||
|
||||
// 存储所有注册了监听的对象,invokeXXXX进行遍历回调,将信息同步
|
||||
private val mAutoPilotBtnListeners: ConcurrentHashMap<String, IMoGoCheckAutoPilotBtnListener> = ConcurrentHashMap()
|
||||
private val mAutoPilotBtnListeners: ConcurrentHashMap<String, IMoGoCheckAutoPilotBtnListener> =
|
||||
ConcurrentHashMap()
|
||||
|
||||
|
||||
/**
|
||||
@@ -31,6 +32,10 @@ object CallerHmiListenerManager : CallerBase() {
|
||||
@Nullable tag: String,
|
||||
@Nullable listener: IMoGoCheckAutoPilotBtnListener
|
||||
) {
|
||||
if (mAutoPilotBtnListeners.containsKey(tag)) {
|
||||
LogUtils.eTag(TAG, "Tag:$tag already exists,please use other tag")
|
||||
return
|
||||
}
|
||||
mAutoPilotBtnListeners[tag] = listener
|
||||
listener.onCheck(mIsChecked)
|
||||
}
|
||||
@@ -40,6 +45,10 @@ object CallerHmiListenerManager : CallerBase() {
|
||||
* @param tag 标记,用来注销监听使用
|
||||
*/
|
||||
fun removeCheckAutoPilotBtnListener(@Nullable tag: String) {
|
||||
if (!mAutoPilotBtnListeners.containsKey(tag)) {
|
||||
LogUtils.eTag(TAG, "Tag:$tag not exists")
|
||||
return
|
||||
}
|
||||
mAutoPilotBtnListeners.remove(tag)
|
||||
}
|
||||
|
||||
@@ -48,12 +57,12 @@ object CallerHmiListenerManager : CallerBase() {
|
||||
* @param isChecked 选中状态
|
||||
*/
|
||||
fun invokeCheckAutoPilotBtnListener(isChecked: Boolean) {
|
||||
LogUtils.dTag(TAG, "isChecked:$isChecked")
|
||||
//LogUtils.dTag(TAG, "isChecked:$isChecked")
|
||||
mIsChecked = isChecked
|
||||
mAutoPilotBtnListeners.forEach {
|
||||
val tag = it.key
|
||||
val listener = it.value
|
||||
LogUtils.dTag(TAG, "tag:$tag listener:$listener")
|
||||
//LogUtils.dTag(TAG, "tag:$tag listener:$listener")
|
||||
listener.onCheck(mIsChecked)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,6 +38,10 @@ object CallerMapLocationListenerManager : CallerBase() {
|
||||
@Nullable tag: String,
|
||||
@Nullable listener: IMoGoMapLocationListener
|
||||
) {
|
||||
if (mMapStyleChangeListeners.containsKey(tag)) {
|
||||
LogUtils.eTag(TAG, "Tag:$tag already exists,please use other tag")
|
||||
return
|
||||
}
|
||||
mMapStyleChangeListeners[tag] = listener
|
||||
listener.onLocationChanged(mLocation)
|
||||
}
|
||||
@@ -47,6 +51,10 @@ object CallerMapLocationListenerManager : CallerBase() {
|
||||
* @param tag 标记,用来注销监听使用
|
||||
*/
|
||||
fun removeListener(@Nullable tag: String) {
|
||||
if (!mMapStyleChangeListeners.containsKey(tag)) {
|
||||
LogUtils.eTag(TAG, "Tag:$tag not exists")
|
||||
return
|
||||
}
|
||||
mMapStyleChangeListeners.remove(tag)
|
||||
}
|
||||
|
||||
@@ -55,6 +63,10 @@ object CallerMapLocationListenerManager : CallerBase() {
|
||||
* @param listener 要删除的监听对象
|
||||
*/
|
||||
fun removeListener(@Nullable listener: IMoGoMapLocationListener) {
|
||||
if (!mMapStyleChangeListeners.containsValue(listener)) {
|
||||
LogUtils.eTag(TAG, "Tag:$listener not exists")
|
||||
return
|
||||
}
|
||||
mMapStyleChangeListeners.forEach {
|
||||
if (it.value == listener) {
|
||||
mMapStyleChangeListeners.remove(it.key)
|
||||
@@ -74,12 +86,12 @@ object CallerMapLocationListenerManager : CallerBase() {
|
||||
* @param location 选中状态
|
||||
*/
|
||||
fun invokeMapLocationChangeListener(location: MogoLocation?) {
|
||||
LogUtils.dTag(TAG, "mapStyleMode:$location")
|
||||
//LogUtils.dTag(TAG, "mapStyleMode:$location")
|
||||
mLocation = location
|
||||
mMapStyleChangeListeners.forEach {
|
||||
val tag = it.key
|
||||
val listener = it.value
|
||||
LogUtils.dTag(TAG, "tag:$tag listener:$listener")
|
||||
//LogUtils.dTag(TAG, "tag:$tag listener:$listener")
|
||||
listener.onLocationChanged(location)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +37,10 @@ object CallerMapStyleListenerManager : CallerBase() {
|
||||
@Nullable tag: String,
|
||||
@Nullable listener: IMoGoMapStyleChangeListener
|
||||
) {
|
||||
if (mMapStyleChangeListeners.containsKey(tag)) {
|
||||
LogUtils.eTag(TAG, "Tag:$tag already exists,please use other tag")
|
||||
return
|
||||
}
|
||||
mMapStyleChangeListeners[tag] = listener
|
||||
listener.onMapStyleModeChange(mMapStyleMode)
|
||||
}
|
||||
@@ -46,6 +50,10 @@ object CallerMapStyleListenerManager : CallerBase() {
|
||||
* @param tag 标记,用来注销监听使用
|
||||
*/
|
||||
fun removeListener(@Nullable tag: String) {
|
||||
if (!mMapStyleChangeListeners.containsKey(tag)) {
|
||||
LogUtils.eTag(TAG, "Tag:$tag not exists")
|
||||
return
|
||||
}
|
||||
mMapStyleChangeListeners.remove(tag)
|
||||
}
|
||||
|
||||
@@ -54,6 +62,10 @@ object CallerMapStyleListenerManager : CallerBase() {
|
||||
* @param listener 要删除的监听对象
|
||||
*/
|
||||
fun removeListener(@Nullable listener: IMoGoMapStyleChangeListener) {
|
||||
if (!mMapStyleChangeListeners.containsValue(listener)) {
|
||||
LogUtils.eTag(TAG, "Tag:$listener not exists")
|
||||
return
|
||||
}
|
||||
mMapStyleChangeListeners.forEach {
|
||||
if (it.value == listener) {
|
||||
mMapStyleChangeListeners.remove(it.key)
|
||||
@@ -73,12 +85,12 @@ object CallerMapStyleListenerManager : CallerBase() {
|
||||
* @param mapStyleMode 选中状态
|
||||
*/
|
||||
fun invokeMapStyleChange(mapStyleMode: Int) {
|
||||
LogUtils.dTag(TAG, "mapStyleMode:$mapStyleMode")
|
||||
//LogUtils.dTag(TAG, "mapStyleMode:$mapStyleMode")
|
||||
mMapStyleMode = mapStyleMode
|
||||
mMapStyleChangeListeners.forEach {
|
||||
val tag = it.key
|
||||
val listener = it.value
|
||||
LogUtils.dTag(TAG, "tag:$tag listener:$listener")
|
||||
//LogUtils.dTag(TAG, "tag:$tag listener:$listener")
|
||||
listener.onMapStyleModeChange(mMapStyleMode)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,8 @@ object CallerObuListenerManager : CallerBase() {
|
||||
private var mObuStatusInfo: ObuStatusInfo = ObuStatusInfo()
|
||||
|
||||
// 存储所有注册了监听的对象,invokeXXXX进行遍历回调,将信息同步
|
||||
private val mObuStatusListeners: ConcurrentHashMap<String, IMoGoObuStatusListener> = ConcurrentHashMap()
|
||||
private val mObuStatusListeners: ConcurrentHashMap<String, IMoGoObuStatusListener> =
|
||||
ConcurrentHashMap()
|
||||
|
||||
/**
|
||||
* 查询 OBU状态
|
||||
@@ -45,6 +46,10 @@ object CallerObuListenerManager : CallerBase() {
|
||||
@Nullable tag: String,
|
||||
@Nullable listener: IMoGoObuStatusListener
|
||||
) {
|
||||
if (mObuStatusListeners.containsKey(tag)) {
|
||||
LogUtils.eTag(TAG, "Tag:$tag already exists,please use other tag")
|
||||
return
|
||||
}
|
||||
mObuStatusListeners[tag] = listener
|
||||
listener.onObuStatusResponse(mObuStatusInfo)
|
||||
}
|
||||
@@ -54,6 +59,10 @@ object CallerObuListenerManager : CallerBase() {
|
||||
* @param tag 标记,用来注销监听使用
|
||||
*/
|
||||
fun removeListener(@Nullable tag: String) {
|
||||
if (!mObuStatusListeners.containsKey(tag)) {
|
||||
LogUtils.eTag(TAG, "Tag:$tag not exists")
|
||||
return
|
||||
}
|
||||
mObuStatusListeners.remove(tag)
|
||||
}
|
||||
|
||||
@@ -62,6 +71,10 @@ object CallerObuListenerManager : CallerBase() {
|
||||
* @param listener 要删除的监听对象
|
||||
*/
|
||||
fun removeListener(@Nullable listener: IMoGoObuStatusListener) {
|
||||
if (!mObuStatusListeners.containsValue(listener)) {
|
||||
LogUtils.eTag(TAG, "Tag:$listener not exists")
|
||||
return
|
||||
}
|
||||
mObuStatusListeners.forEach {
|
||||
if (it.value == listener) {
|
||||
mObuStatusListeners.remove(it.key)
|
||||
@@ -81,12 +94,12 @@ object CallerObuListenerManager : CallerBase() {
|
||||
* @param obuStatusInfo 选中状态
|
||||
*/
|
||||
fun invokeListener(obuStatusInfo: ObuStatusInfo) {
|
||||
LogUtils.dTag(TAG, "obuStatusInfo:$obuStatusInfo")
|
||||
//LogUtils.dTag(TAG, "obuStatusInfo:$obuStatusInfo")
|
||||
mObuStatusInfo = obuStatusInfo
|
||||
mObuStatusListeners.forEach {
|
||||
val tag = it.key
|
||||
val listener = it.value
|
||||
LogUtils.dTag(TAG, "tag:$tag listener:$listener")
|
||||
//LogUtils.dTag(TAG, "tag:$tag listener:$listener")
|
||||
listener.onObuStatusResponse(mObuStatusInfo)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.mogo.eagle.core.function.call.trafficlight
|
||||
import androidx.annotation.Nullable
|
||||
import com.mogo.eagle.core.data.trafficlight.TrafficLightResult
|
||||
import com.mogo.eagle.core.function.api.trafficlight.IMoGoTrafficLightListener
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
|
||||
import com.mogo.eagle.core.utilcode.util.LogUtils
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
object CallTrafficLightListenerManager {
|
||||
@@ -13,7 +13,7 @@ object CallTrafficLightListenerManager {
|
||||
private val M_TRAFFIC_LIGHT_LISTENER: ConcurrentHashMap<String, IMoGoTrafficLightListener> =
|
||||
ConcurrentHashMap()
|
||||
|
||||
private var trafficLightResult:TrafficLightResult? = null
|
||||
private var trafficLightResult: TrafficLightResult? = null
|
||||
|
||||
/**
|
||||
* 添加监听
|
||||
@@ -24,6 +24,10 @@ object CallTrafficLightListenerManager {
|
||||
@Nullable tag: String,
|
||||
@Nullable listener: IMoGoTrafficLightListener
|
||||
) {
|
||||
if (M_TRAFFIC_LIGHT_LISTENER.containsKey(tag)) {
|
||||
LogUtils.eTag(TAG, "Tag:$tag already exists,please use other tag")
|
||||
return
|
||||
}
|
||||
trafficLightResult?.let {
|
||||
listener.onTrafficLightStatus(it)
|
||||
}
|
||||
@@ -35,6 +39,10 @@ object CallTrafficLightListenerManager {
|
||||
* @param tag 标记,用来注销监听使用
|
||||
*/
|
||||
fun unRegisterTrafficLightListener(@Nullable tag: String) {
|
||||
if (!M_TRAFFIC_LIGHT_LISTENER.containsKey(tag)) {
|
||||
LogUtils.eTag(TAG, "Tag:$tag not exists")
|
||||
return
|
||||
}
|
||||
M_TRAFFIC_LIGHT_LISTENER.remove(tag)
|
||||
}
|
||||
|
||||
@@ -43,6 +51,10 @@ object CallTrafficLightListenerManager {
|
||||
* @param listener 要删除的监听对象
|
||||
*/
|
||||
fun unRegisterTrafficLightListener(@Nullable listener: IMoGoTrafficLightListener) {
|
||||
if (!M_TRAFFIC_LIGHT_LISTENER.containsValue(listener)) {
|
||||
LogUtils.eTag(TAG, "listener:$listener not exists")
|
||||
return
|
||||
}
|
||||
M_TRAFFIC_LIGHT_LISTENER.forEach {
|
||||
if (it.value == listener) {
|
||||
M_TRAFFIC_LIGHT_LISTENER.remove(it.key)
|
||||
@@ -54,13 +66,13 @@ object CallTrafficLightListenerManager {
|
||||
this.trafficLightResult = trafficLightResult
|
||||
M_TRAFFIC_LIGHT_LISTENER.forEach {
|
||||
val tag = it.key
|
||||
Logger.d(TAG, "invokeTrafficLightStatus tag is : $tag")
|
||||
//LogUtils.dTag(TAG, "invokeTrafficLightStatus tag is : $tag")
|
||||
val listener = it.value
|
||||
listener.onTrafficLightStatus(trafficLightResult)
|
||||
}
|
||||
}
|
||||
|
||||
fun resetTrafficLightData(){
|
||||
fun resetTrafficLightData() {
|
||||
trafficLightResult = null
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user