[6.5.0] fix bug of request auth and result
This commit is contained in:
@@ -1,73 +1,62 @@
|
||||
package com.mogo.eagle.core.function.call.map
|
||||
|
||||
import com.mogo.eagle.core.data.deva.chain.ChainConstant
|
||||
import com.mogo.eagle.core.data.road.RoadCameraLive
|
||||
import com.mogo.eagle.core.function.api.map.road.IMoGoMapRoadListener
|
||||
import com.mogo.eagle.core.function.call.base.CallerBase
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_MAP
|
||||
import com.zhidaoauto.map.data.road.RoadCross
|
||||
import com.zhidaoauto.map.data.road.StopLine
|
||||
import com.zhjt.service.chain.ChainLog
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
import kotlin.properties.Delegates
|
||||
|
||||
object CallerMapRoadListenerManager {
|
||||
object CallerMapRoadListenerManager : CallerBase<IMoGoMapRoadListener>() {
|
||||
|
||||
interface OnRoadListener {
|
||||
private var mRoadId: String? = null
|
||||
private var mStopLine: StopLine? = null
|
||||
private var mRoadChange = false
|
||||
private var mRoadCross: RoadCross? = null
|
||||
|
||||
fun onRoadIdInfo(roadId: String) {}
|
||||
|
||||
fun onStopLineInfo(info: StopLine) {}
|
||||
|
||||
fun onRoadChange(cross: Boolean, roadCross: RoadCross? = null) {}
|
||||
}
|
||||
|
||||
private val listeners by lazy {
|
||||
ConcurrentHashMap<String, OnRoadListener>()
|
||||
}
|
||||
|
||||
fun registerRoadListener(tag: String, listener: OnRoadListener) {
|
||||
if (listeners.contains(tag)) {
|
||||
return
|
||||
private var mCross: Int by Delegates.observable(-1) { _, oldValue, newValue ->
|
||||
// if (oldValue != newValue) { //todo emArrow test
|
||||
CallerLogger.d("$M_MAP onRoadChange observable", newValue)
|
||||
M_LISTENERS.forEach { entry ->
|
||||
// false:1,2, 离开路口,进入路段
|
||||
// true: 进入路口
|
||||
mRoadChange = !(newValue == 1 || newValue == 2)
|
||||
entry.value.onRoadChange(mRoadChange, mRoadCross)
|
||||
}
|
||||
listeners[tag] = listener
|
||||
// }
|
||||
}
|
||||
|
||||
fun unRegisterRoadListener(tag: String) {
|
||||
if (!listeners.contains(tag)) {
|
||||
return
|
||||
override fun doSomeAfterAddListener(tag: String, listener: IMoGoMapRoadListener) {
|
||||
super.doSomeAfterAddListener(tag, listener)
|
||||
mRoadId?.let {
|
||||
listener.onRoadIdInfo(it)
|
||||
}
|
||||
mStopLine?.let {
|
||||
listener.onStopLineInfo(it)
|
||||
}
|
||||
if(mCross != -1 && mRoadCross != null){
|
||||
listener.onRoadChange(mRoadChange, mRoadCross)
|
||||
}
|
||||
listeners.remove(tag)
|
||||
}
|
||||
|
||||
|
||||
fun invokeListenersOnRoadIdGet(roadId: String) {
|
||||
listeners.forEach { entry ->
|
||||
mRoadId = roadId
|
||||
M_LISTENERS.forEach { entry ->
|
||||
entry.value.onRoadIdInfo(roadId)
|
||||
}
|
||||
}
|
||||
|
||||
private var mStopLine:StopLine? = null
|
||||
|
||||
fun invokeListenersOnStopLineGet(stopLine: StopLine) {
|
||||
mStopLine = stopLine
|
||||
listeners.forEach { entry ->
|
||||
M_LISTENERS.forEach { entry ->
|
||||
entry.value.onStopLineInfo(stopLine)
|
||||
}
|
||||
}
|
||||
|
||||
private var mCross: Int by Delegates.observable(-1) { _, oldValue, newValue ->
|
||||
// if (oldValue != newValue) {
|
||||
CallerLogger.d("$M_MAP onRoadChange observable", newValue)
|
||||
listeners.forEach { entry ->
|
||||
when (newValue) {
|
||||
1, 2 -> entry.value.onRoadChange(false, mRoadCross)
|
||||
else -> entry.value.onRoadChange(true, mRoadCross)
|
||||
}
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
||||
private var mRoadCross: RoadCross? = null
|
||||
|
||||
fun getCrossInfo(): RoadCross? {
|
||||
return mRoadCross
|
||||
}
|
||||
@@ -79,10 +68,24 @@ object CallerMapRoadListenerManager {
|
||||
paramIndexes = [0, 1]
|
||||
)
|
||||
fun invokeRoadChange(cross: Int, roadCross: RoadCross) {
|
||||
CallerLogger.d("$M_MAP onRoadChange", "oldValue: $mCross , " + "mStopLine:${mStopLine?.distance}" +
|
||||
"newValue: $cross , oldCross:$mRoadCross , newCross:$roadCross")
|
||||
CallerLogger.d(
|
||||
"$M_MAP onRoadChange", "oldValue: $mCross , " + "mStopLine:${mStopLine?.distance}" +
|
||||
"newValue: $cross , oldCross:$mRoadCross , newCross:$roadCross"
|
||||
)
|
||||
mCross = cross
|
||||
mRoadCross = roadCross
|
||||
|
||||
}
|
||||
|
||||
@ChainLog(
|
||||
linkChainLog = ChainConstant.CHAIN_TYPE_STATUS,
|
||||
linkCode = ChainConstant.CHAIN_SOURCE_MAP,
|
||||
nodeAliasCode = ChainConstant.CHAIN_CODE_HD_MAP_ROAD_LIVE,
|
||||
paramIndexes = [0]
|
||||
)
|
||||
fun invokeRoadCrossLive(info: RoadCameraLive){
|
||||
M_LISTENERS.forEach { entry ->
|
||||
entry.value.onCrossLiveInfo(info)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user