[Add function]重构了当前位置获取的监听方式;
// 订阅监听 CallerMapLocationListenerManager.addListener(TAG, IMoGoMapLocationListener) // 主动查询 CallerMapLocationListenerManager.INSTANCE.getCurrentLocation() Signed-off-by: donghongyu <donghongyu@zhidaoauto.com>
This commit is contained in:
@@ -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 java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
/**
|
||||
* @author xiaoyuzhou
|
||||
@@ -21,8 +22,8 @@ object CallerAutoPilotStatusListenerManager : CallerBase() {
|
||||
private var mAutopilotStatusInfo: AutopilotStatusInfo = AutopilotStatusInfo()
|
||||
|
||||
// 存储所有注册了监听的对象,invokeXXXX进行遍历回调,将信息同步
|
||||
private val M_AUTOPILOT_STATUS_LISTENERS: HashMap<String, IMoGoAutopilotStatusListener> =
|
||||
HashMap()
|
||||
private val M_AUTOPILOT_STATUS_LISTENERS: ConcurrentHashMap<String, IMoGoAutopilotStatusListener> =
|
||||
ConcurrentHashMap()
|
||||
|
||||
/**
|
||||
* 查询AutoPilot状态
|
||||
|
||||
@@ -5,6 +5,7 @@ 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 java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
/**
|
||||
* @author xiaoyuzhou
|
||||
@@ -15,8 +16,8 @@ object CallerAutopilotCarStatusListenerManager : CallerBase() {
|
||||
private val TAG = "CallerAutopilotCarStatusListenerManager"
|
||||
|
||||
// 存储所有注册了监听的对象,invokeXXXX进行遍历回调,将信息同步
|
||||
private val M_AUTOPILOT_STATUS_LISTENERS: HashMap<String, IMoGoAutopilotCarStateListener> =
|
||||
HashMap()
|
||||
private val M_AUTOPILOT_STATUS_LISTENERS: ConcurrentHashMap<String, IMoGoAutopilotCarStateListener> =
|
||||
ConcurrentHashMap()
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,6 +6,7 @@ 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 java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
/**
|
||||
* @author xiaoyuzhou
|
||||
@@ -16,8 +17,8 @@ object CallerAutopilotIdentifyListenerManager : CallerBase() {
|
||||
private val TAG = "CallerAutopilotIdentifyListenerManager"
|
||||
|
||||
// 存储所有注册了监听的对象,invokeXXXX进行遍历回调,将信息同步
|
||||
private val M_AUTOPILOT_IDENTIFY_LISTENERS: HashMap<String, IMoGoAutopilotIdentifyListener> =
|
||||
HashMap()
|
||||
private val M_AUTOPILOT_IDENTIFY_LISTENERS: ConcurrentHashMap<String, IMoGoAutopilotIdentifyListener> =
|
||||
ConcurrentHashMap()
|
||||
|
||||
/**
|
||||
* 添加监听
|
||||
|
||||
@@ -4,6 +4,7 @@ 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
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
/**
|
||||
* @author xiaoyuzhou
|
||||
@@ -18,7 +19,7 @@ object CallerHmiListenerManager : CallerBase() {
|
||||
private var mIsChecked: Boolean = false
|
||||
|
||||
// 存储所有注册了监听的对象,invokeXXXX进行遍历回调,将信息同步
|
||||
private val mAutoPilotBtnListeners: HashMap<String, IMoGoCheckAutoPilotBtnListener> = HashMap()
|
||||
private val mAutoPilotBtnListeners: ConcurrentHashMap<String, IMoGoCheckAutoPilotBtnListener> = ConcurrentHashMap()
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
package com.mogo.eagle.core.function.call.map
|
||||
|
||||
import androidx.annotation.Nullable
|
||||
import com.mogo.eagle.core.data.map.MogoLocation
|
||||
import com.mogo.eagle.core.function.api.map.listener.IMoGoMapLocationListener
|
||||
import com.mogo.eagle.core.function.call.base.CallerBase
|
||||
import com.mogo.eagle.core.utilcode.util.LogUtils
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
/**
|
||||
* @author xiaoyuzhou
|
||||
* @date 2021/9/30 5:48 下午
|
||||
* 地图 位置改变 监听管理
|
||||
*/
|
||||
object CallerMapLocationListenerManager : CallerBase() {
|
||||
private val TAG = "CallerMapLocationListenerManager"
|
||||
|
||||
// 记录地图最后一次位置
|
||||
private var mLocation: MogoLocation? = null
|
||||
|
||||
// 存储所有注册了监听的对象,invokeXXXX进行遍历回调,将信息同步
|
||||
private val mMapStyleChangeListeners: ConcurrentHashMap<String, IMoGoMapLocationListener> =
|
||||
ConcurrentHashMap()
|
||||
|
||||
/**
|
||||
* 获取当前经纬度
|
||||
*/
|
||||
fun getCurrentLocation(): MogoLocation? {
|
||||
return mLocation
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加 地图样式改变 监听
|
||||
* @param tag 标记,用来注销监听使用
|
||||
* @param listener 监听回调
|
||||
*/
|
||||
fun addListener(
|
||||
@Nullable tag: String,
|
||||
@Nullable listener: IMoGoMapLocationListener
|
||||
) {
|
||||
mMapStyleChangeListeners[tag] = listener
|
||||
listener.onLocationChanged(mLocation)
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除 地图样式改变 监听
|
||||
* @param tag 标记,用来注销监听使用
|
||||
*/
|
||||
fun removeListener(@Nullable tag: String) {
|
||||
mMapStyleChangeListeners.remove(tag)
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除 地图样式改变 监听
|
||||
* @param listener 要删除的监听对象
|
||||
*/
|
||||
fun removeListener(@Nullable listener: IMoGoMapLocationListener) {
|
||||
mMapStyleChangeListeners.forEach {
|
||||
if (it.value == listener) {
|
||||
mMapStyleChangeListeners.remove(it.key)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 触发 地图样式改变 监听
|
||||
*/
|
||||
fun invokeMapLocationChangeListener() {
|
||||
invokeMapLocationChangeListener(mLocation)
|
||||
}
|
||||
|
||||
/**
|
||||
* 触发 地图样式改变 监听
|
||||
* @param location 选中状态
|
||||
*/
|
||||
fun invokeMapLocationChangeListener(location: MogoLocation?) {
|
||||
LogUtils.dTag(TAG, "mapStyleMode:$location")
|
||||
mLocation = location
|
||||
mMapStyleChangeListeners.forEach {
|
||||
val tag = it.key
|
||||
val listener = it.value
|
||||
LogUtils.dTag(TAG, "tag:$tag listener:$listener")
|
||||
listener.onLocationChanged(location)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,23 +1,24 @@
|
||||
package com.mogo.eagle.core.function.call.map
|
||||
|
||||
import androidx.annotation.Nullable
|
||||
import com.mogo.eagle.core.function.api.map.hd.IMoGoMapStyleChangeListener
|
||||
import com.mogo.eagle.core.function.api.map.listener.IMoGoMapStyleChangeListener
|
||||
import com.mogo.eagle.core.function.call.base.CallerBase
|
||||
import com.mogo.eagle.core.utilcode.util.LogUtils
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
/**
|
||||
* @author xiaoyuzhou
|
||||
* @date 2021/9/30 5:48 下午
|
||||
* 地图 监听管理
|
||||
* 地图 样式改变 监听管理
|
||||
*/
|
||||
object CallerMapListenerManager : CallerBase() {
|
||||
private val TAG = "CallerMapListenerManager"
|
||||
object CallerMapStyleListenerManager : CallerBase() {
|
||||
private val TAG = "CallerMapStyleListenerManager"
|
||||
|
||||
// 记录地图样式
|
||||
private var mMapStyleMode = 0
|
||||
|
||||
// 存储所有注册了监听的对象,invokeXXXX进行遍历回调,将信息同步
|
||||
private val mMapStyleChangeListeners: HashMap<String, IMoGoMapStyleChangeListener> = HashMap()
|
||||
private val mMapStyleChangeListeners: ConcurrentHashMap<String, IMoGoMapStyleChangeListener> = ConcurrentHashMap()
|
||||
|
||||
/**
|
||||
* 添加 地图样式改变 监听
|
||||
@@ -6,6 +6,7 @@ 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
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
/**
|
||||
* @author xiaoyuzhou
|
||||
@@ -19,7 +20,7 @@ object CallerObuListenerManager : CallerBase() {
|
||||
private var mObuStatusInfo: ObuStatusInfo = ObuStatusInfo()
|
||||
|
||||
// 存储所有注册了监听的对象,invokeXXXX进行遍历回调,将信息同步
|
||||
private val mObuStatusListeners: HashMap<String, IMoGoObuStatusListener> = HashMap()
|
||||
private val mObuStatusListeners: ConcurrentHashMap<String, IMoGoObuStatusListener> = ConcurrentHashMap()
|
||||
|
||||
/**
|
||||
* 查询 OBU状态
|
||||
|
||||
@@ -4,13 +4,14 @@ 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 java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
object CallTrafficLightListenerManager {
|
||||
|
||||
private val TAG = "CallTrafficLightListenerManager"
|
||||
|
||||
private val M_TRAFFIC_LIGHT_LISTENER: HashMap<String, IMoGoTrafficLightListener> =
|
||||
HashMap()
|
||||
private val M_TRAFFIC_LIGHT_LISTENER: ConcurrentHashMap<String, IMoGoTrafficLightListener> =
|
||||
ConcurrentHashMap()
|
||||
|
||||
private var trafficLightResult:TrafficLightResult? = null
|
||||
|
||||
|
||||
Reference in New Issue
Block a user