[dev_arch_opt_3.0][fix]修正因位置回调重构造成的v2x事件不显示问题
This commit is contained in:
@@ -13,21 +13,9 @@ import java.util.concurrent.ConcurrentHashMap
|
||||
object CallerMapLocationListenerManager : CallerBase<Any>() {
|
||||
|
||||
// 记录地图最后一次位置
|
||||
@Volatile
|
||||
private var mLocation: MogoLocation? = null
|
||||
|
||||
/**
|
||||
* 记录最后一次高精坐标的位置
|
||||
*/
|
||||
private var mGpsLocation: MogoLocation? = null
|
||||
|
||||
// 存储所有注册了监听的对象,invokeXXXX进行遍历回调,将信息同步
|
||||
private val mMapStyleChangeListeners: ConcurrentHashMap<String, IMoGoMapLocationListener> =
|
||||
ConcurrentHashMap()
|
||||
|
||||
|
||||
// 高精坐标回调
|
||||
private val mGpsChangedListeners: ConcurrentHashMap<String, IMoGoMapLocationListener> = ConcurrentHashMap()
|
||||
|
||||
/**
|
||||
* 获取当前经纬度
|
||||
*/
|
||||
@@ -35,103 +23,7 @@ object CallerMapLocationListenerManager : CallerBase<Any>() {
|
||||
return mLocation
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前高精坐标
|
||||
*/
|
||||
fun getCurrentGpsLocation(): MogoLocation? {
|
||||
return mGpsLocation
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加 地图样式改变 监听
|
||||
* @param tag 标记,用来注销监听使用
|
||||
* @param listener 监听回调
|
||||
*/
|
||||
fun addListener(tag: String, listener: IMoGoMapLocationListener, isGps: Boolean) {
|
||||
if (!isGps) {
|
||||
if (mMapStyleChangeListeners.containsKey(tag)) {
|
||||
return
|
||||
}
|
||||
mMapStyleChangeListeners[tag] = listener
|
||||
listener.onLocationChanged(mLocation, 0, isGps)
|
||||
} else {
|
||||
if (mGpsChangedListeners.containsKey(tag)) {
|
||||
return
|
||||
}
|
||||
mGpsChangedListeners[tag] = listener
|
||||
listener.onLocationChanged(mGpsLocation, 0, isGps)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除 地图样式改变 监听
|
||||
* @param tag 标记,用来注销监听使用
|
||||
*/
|
||||
fun removeListener(tag: String, isGps: Boolean) {
|
||||
if (!isGps) {
|
||||
if (!mMapStyleChangeListeners.containsKey(tag)) {
|
||||
return
|
||||
}
|
||||
mMapStyleChangeListeners.remove(tag)
|
||||
} else {
|
||||
if (!mGpsChangedListeners.containsKey(tag)) {
|
||||
return
|
||||
}
|
||||
mGpsChangedListeners.remove(tag)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除 地图样式改变 监听
|
||||
* @param listener 要删除的监听对象
|
||||
*/
|
||||
fun removeListener(listener: IMoGoMapLocationListener, isGps: Boolean) {
|
||||
if (!isGps) {
|
||||
if (!mMapStyleChangeListeners.containsValue(listener)) {
|
||||
return
|
||||
}
|
||||
mMapStyleChangeListeners.forEach {
|
||||
if (it.value == listener) {
|
||||
mMapStyleChangeListeners.remove(it.key)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!mGpsChangedListeners.containsValue(listener)) {
|
||||
return
|
||||
}
|
||||
mGpsChangedListeners.forEach {
|
||||
if (it.value == listener) {
|
||||
mGpsChangedListeners.remove(it.key)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 触发 地图样式改变 监听
|
||||
*/
|
||||
fun invokeMapLocationChangeListener() {
|
||||
invokeMapLocationChangeListener(mLocation, 0, false)
|
||||
}
|
||||
|
||||
/**
|
||||
* 触发 地图样式改变 监听
|
||||
* @param location 选中状态
|
||||
*/
|
||||
fun invokeMapLocationChangeListener(location: MogoLocation?, from: Int, isGps: Boolean) {
|
||||
if (!isGps) {
|
||||
mLocation = location
|
||||
mMapStyleChangeListeners.forEach {
|
||||
val listener = it.value
|
||||
listener.onLocationChanged(location, from, isGps)
|
||||
}
|
||||
} else {
|
||||
mGpsLocation = location
|
||||
mGpsChangedListeners.forEach {
|
||||
it.value.onLocationChanged(location, from, isGps)
|
||||
}
|
||||
}
|
||||
fun setCurrentLocation(location: MogoLocation) {
|
||||
mLocation = location
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,7 @@ import androidx.lifecycle.LifecycleOwner
|
||||
import com.mogo.eagle.core.data.config.FunctionBuildConfig
|
||||
import com.mogo.eagle.core.data.map.*
|
||||
import com.mogo.eagle.core.data.map.MapRoadInfo.StopLine
|
||||
import com.mogo.eagle.core.function.call.autopilot.*
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapRoadListenerManager.OnRoadListener
|
||||
import com.mogo.eagle.core.function.call.map.CallerVisualAngleManager.Scene.*
|
||||
import com.mogo.eagle.core.utilcode.kotlin.lifeCycleOwner
|
||||
@@ -23,6 +24,7 @@ import com.zhidaoauto.map.sdk.open.tools.MapTools
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.android.asCoroutineDispatcher
|
||||
import kotlinx.coroutines.internal.synchronized
|
||||
import mogo.telematics.pad.MessagePad.GnssInfo
|
||||
import java.util.*
|
||||
import java.util.concurrent.TimeUnit
|
||||
import java.util.concurrent.TimeUnit.SECONDS
|
||||
@@ -63,7 +65,7 @@ object CallerVisualAngleManager {
|
||||
val displayThreshold: Long //最大展示时长 > 0; 表示最长展示多长时间, -1 表示,一直展示,直到触发默认视角, 0: 默认视角专用值,
|
||||
}
|
||||
|
||||
private val triggerLocation = AtomicReference<MogoLocation>()
|
||||
private val triggerLocation = AtomicReference<GnssInfo>()
|
||||
|
||||
private val distanceOfCarToStopLine = AtomicReference(0.0)
|
||||
|
||||
@@ -76,7 +78,7 @@ object CallerVisualAngleManager {
|
||||
override fun onRoadIdInfo(roadId: String) {
|
||||
this.roadId.set(roadId)
|
||||
Log.d(TAG, "-- onRoadIdInfo --: prev: ${this.triggerRoadId.get()} -> curr: $roadId")
|
||||
val loc = CallerMapLocationListenerManager.getCurrentLocation()
|
||||
val loc = CallerChassisLocationGCJ20ListenerManager.getChassisLocationGCJ02()
|
||||
var triggerClose = false
|
||||
val distance = distanceOfCarToStopLine.get() + 5
|
||||
if (hasCrossRoad && distance > 0) {
|
||||
@@ -109,7 +111,7 @@ object CallerVisualAngleManager {
|
||||
hasCrossRoad = true
|
||||
triggerRoadId.set(this.roadId.get())
|
||||
distanceOfCarToStopLine.set(info.distanceOfCarToStopLine)
|
||||
triggerLocation.set(CallerMapLocationListenerManager.getCurrentLocation())
|
||||
triggerLocation.set(CallerChassisLocationGCJ20ListenerManager.getChassisLocationGCJ02())
|
||||
changeVisualAngle(CrossRoad(true))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user