[Add function]重构了当前位置获取的监听方式;
// 订阅监听 CallerMapLocationListenerManager.addListener(TAG, IMoGoMapLocationListener) // 主动查询 CallerMapLocationListenerManager.INSTANCE.getCurrentLocation() Signed-off-by: donghongyu <donghongyu@zhidaoauto.com>
This commit is contained in:
@@ -14,17 +14,21 @@ import com.mogo.eagle.core.data.autopilot.AutopilotStationInfo
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo
|
||||
import com.mogo.eagle.core.data.config.FunctionBuildConfig
|
||||
import com.mogo.eagle.core.data.constants.MoGoConfig
|
||||
import com.mogo.eagle.core.data.map.MogoLocation
|
||||
import com.mogo.eagle.core.data.obu.ObuStatusInfo
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotCarStateListener
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
|
||||
import com.mogo.eagle.core.function.api.map.listener.IMoGoMapLocationListener
|
||||
import com.mogo.eagle.core.function.api.obu.IMoGoObuStatusListener
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotCarStatusListenerManager
|
||||
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapLocationListenerManager
|
||||
import com.mogo.eagle.core.function.call.obu.CallerOBUManager
|
||||
import com.mogo.eagle.core.function.call.obu.CallerObuListenerManager
|
||||
import com.mogo.eagle.core.function.hmi.R
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
|
||||
import com.mogo.eagle.core.utilcode.util.AppUtils
|
||||
import com.mogo.eagle.core.utilcode.util.GsonUtils
|
||||
import com.mogo.eagle.core.utilcode.util.ToastUtils
|
||||
@@ -46,7 +50,7 @@ class DebugSettingView @JvmOverloads constructor(
|
||||
attrs: AttributeSet? = null,
|
||||
defStyleAttr: Int = 0
|
||||
) : ConstraintLayout(context, attrs, defStyleAttr), IMoGoObuStatusListener,
|
||||
IMoGoAutopilotStatusListener, IMoGoAutopilotCarStateListener {
|
||||
IMoGoAutopilotStatusListener, IMoGoAutopilotCarStateListener, IMoGoMapLocationListener {
|
||||
|
||||
private val TAG = "DebugSettingView"
|
||||
|
||||
@@ -60,6 +64,7 @@ class DebugSettingView @JvmOverloads constructor(
|
||||
CallerObuListenerManager.addListener(TAG, this)
|
||||
CallerAutoPilotStatusListenerManager.addListener(TAG, this)
|
||||
CallerAutopilotCarStatusListenerManager.addListener(TAG, this)
|
||||
CallerMapLocationListenerManager.addListener(TAG, this)
|
||||
}
|
||||
|
||||
override fun onDetachedFromWindow() {
|
||||
@@ -67,6 +72,7 @@ class DebugSettingView @JvmOverloads constructor(
|
||||
CallerObuListenerManager.removeListener(TAG)
|
||||
CallerAutoPilotStatusListenerManager.removeListener(TAG)
|
||||
CallerAutopilotCarStatusListenerManager.removeListener(TAG)
|
||||
CallerMapLocationListenerManager.removeListener(TAG)
|
||||
}
|
||||
|
||||
private fun initView() {
|
||||
@@ -239,4 +245,8 @@ class DebugSettingView @JvmOverloads constructor(
|
||||
|
||||
}
|
||||
|
||||
override fun onLocationChanged(location: MogoLocation?) {
|
||||
Logger.d(TAG, "location:$location")
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package com.mogo.eagle.core.function.api.map.hd;
|
||||
|
||||
import com.mogo.eagle.core.data.map.MogoLocation;
|
||||
|
||||
/**
|
||||
* @author xiaoyuzhou
|
||||
* @date 2021/11/1 7:17 下午
|
||||
* 地图定位回调
|
||||
*/
|
||||
public interface IMoGoMapLocationListener {
|
||||
|
||||
/**
|
||||
* 定位发生改变
|
||||
*
|
||||
* @param location 新定位点
|
||||
*/
|
||||
void onLocationChanged(MogoLocation location);
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.mogo.eagle.core.function.api.map.listener
|
||||
|
||||
import com.mogo.eagle.core.data.map.MogoLocation
|
||||
|
||||
/**
|
||||
* @author xiaoyuzhou
|
||||
* @date 2021/11/1 7:17 下午
|
||||
* 地图定位回调
|
||||
*/
|
||||
interface IMoGoMapLocationListener {
|
||||
/**
|
||||
* 定位发生改变
|
||||
*
|
||||
* @param location 新定位点
|
||||
*/
|
||||
fun onLocationChanged(location: MogoLocation?)
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mogo.eagle.core.function.api.map.hd
|
||||
package com.mogo.eagle.core.function.api.map.listener
|
||||
|
||||
/**
|
||||
*@author xiaoyuzhou
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@ import com.mogo.service.cloud.location.IMogoLocationInfoService;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
@Keep
|
||||
|
||||
public class MogoLocationInfoServices implements IMogoLocationInfoService {
|
||||
|
||||
private static final String TAG = "MogoLocationInfoServices-sdk";
|
||||
@@ -40,7 +39,7 @@ public class MogoLocationInfoServices implements IMogoLocationInfoService {
|
||||
@Override
|
||||
public void provideLocation(MogoLocation location) {
|
||||
mLocation = location;
|
||||
Logger.d(TAG, "sdk - provideLocation");
|
||||
// Logger.d(TAG, "sdk - provideLocation");
|
||||
}
|
||||
|
||||
public MogoLocation getLocation() {
|
||||
|
||||
@@ -23,7 +23,9 @@ import com.mogo.commons.constants.SharedPrefsConstants;
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.eagle.core.data.config.FunctionBuildConfig;
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.eagle.core.data.map.MogoLocation;
|
||||
import com.mogo.eagle.core.function.call.map.CallerLocationUpdaterManager;
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapLocationListenerManager;
|
||||
import com.mogo.eagle.core.utilcode.mogo.toast.TipToast;
|
||||
import com.mogo.map.IMogoMap;
|
||||
import com.mogo.map.IMogoMapView;
|
||||
@@ -732,6 +734,9 @@ public class AMapViewWrapper implements IMogoMapView,
|
||||
|
||||
@Override
|
||||
public void onLocationChanged(@NotNull com.zhidaoauto.map.sdk.open.location.MogoLocation location) {
|
||||
MogoLocation mLastLocation = ObjectUtils.fromLocation(location);
|
||||
CallerMapLocationListenerManager.INSTANCE.invokeMapLocationChangeListener(mLastLocation);
|
||||
|
||||
Location sysLocation = new Location(location.getProvider());
|
||||
sysLocation.setAltitude(location.getAltitude());
|
||||
sysLocation.setLatitude(location.getLat());
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.mogo.map.impl.custom.location;
|
||||
import android.content.Context;
|
||||
import android.os.Trace;
|
||||
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapLocationListenerManager;
|
||||
import com.mogo.map.impl.custom.utils.ObjectUtils;
|
||||
import com.mogo.map.location.IMogoLocationClient;
|
||||
import com.mogo.map.location.IMogoLocationListener;
|
||||
@@ -122,6 +123,7 @@ public class ALocationClient implements IMogoLocationClient {
|
||||
}
|
||||
Trace.beginSection( "timer.onLocationChanged" );
|
||||
mLastLocation = ObjectUtils.fromLocation( location );
|
||||
CallerMapLocationListenerManager.INSTANCE.invokeMapLocationChangeListener(mLastLocation);
|
||||
Set< IMogoLocationListener > listeners = MogoLocationListenerRegister.getInstance().getListeners();
|
||||
synchronized ( listeners ) {
|
||||
Iterator< IMogoLocationListener > listenerIterator = listeners.iterator();
|
||||
|
||||
Reference in New Issue
Block a user