diff --git a/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/impl/AbsV2XScenario.java b/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/impl/AbsV2XScenario.java index cd72feafbd..8fe0d5b892 100644 --- a/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/impl/AbsV2XScenario.java +++ b/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/impl/AbsV2XScenario.java @@ -7,6 +7,8 @@ import com.mogo.eagle.core.data.map.entity.V2XMessageEntity; import com.mogo.eagle.core.function.v2x.events.scenario.IV2XScenario; import com.mogo.eagle.core.function.v2x.events.scenario.view.IV2XMarker; +import java.util.concurrent.atomic.AtomicReference; + /** * author : donghongyu * e-mail : 1358506549@qq.com @@ -17,7 +19,7 @@ import com.mogo.eagle.core.function.v2x.events.scenario.view.IV2XMarker; public abstract class AbsV2XScenario implements IV2XScenario { protected String TAG = "AbsV2XScenario"; private IV2XMarker mV2XMarker; - private V2XMessageEntity mV2XMessageEntity; + private static final AtomicReference mV2XMessageEntity = new AtomicReference<>(); protected AbsV2XScenario() { } @@ -33,7 +35,6 @@ public abstract class AbsV2XScenario implements IV2XScenario { * 释放资源 */ public void release() { - mV2XMessageEntity = null; mV2XMarker = null; } @@ -46,19 +47,19 @@ public abstract class AbsV2XScenario implements IV2XScenario { } public void setV2XMessageEntity(@Nullable V2XMessageEntity mV2XMessageEntity) { - this.mV2XMessageEntity = mV2XMessageEntity; + this.mV2XMessageEntity.set(mV2XMessageEntity); } public V2XMessageEntity getV2XMessageEntity() { - return mV2XMessageEntity; + return mV2XMessageEntity.get(); } @Override public boolean isSameScenario(@Nullable V2XMessageEntity v2XMessageEntity) { - if (mV2XMessageEntity == null) { + V2XMessageEntity old = mV2XMessageEntity.get(); + if (old == null) { return false; } - return mV2XMessageEntity.equals(v2XMessageEntity); + return old.equals(v2XMessageEntity); } - } diff --git a/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/impl/V2XScenarioManager.java b/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/impl/V2XScenarioManager.java index a5addc16c7..a8f916dc9f 100644 --- a/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/impl/V2XScenarioManager.java +++ b/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/impl/V2XScenarioManager.java @@ -21,6 +21,8 @@ import com.mogo.map.MogoMapUIController; import com.mogo.map.uicontroller.IMogoMapUIController; import com.mogo.map.uicontroller.VisualAngleMode; +import java.util.concurrent.atomic.AtomicReference; + /** * author : donghongyu * e-mail : 1358506549@qq.com diff --git a/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/scene/road/V2XRoadEventScenario.java b/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/scene/road/V2XRoadEventScenario.java index 88e13b8217..12c6437810 100644 --- a/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/scene/road/V2XRoadEventScenario.java +++ b/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/scene/road/V2XRoadEventScenario.java @@ -1,6 +1,5 @@ package com.mogo.eagle.core.function.v2x.events.scenario.scene.road; -import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_V2X; import android.util.Log; @@ -26,7 +25,6 @@ import com.mogo.eagle.core.function.v2x.events.manager.V2XStatusManager; import com.mogo.eagle.core.function.v2x.events.scenario.impl.AbsV2XScenario; import com.mogo.eagle.core.function.v2x.events.scenario.view.IV2XMarker; import com.mogo.eagle.core.network.utils.GsonUtil; -import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger; import java.util.HashMap; import java.util.Map; import java.util.concurrent.TimeUnit; @@ -41,6 +39,9 @@ import java.util.concurrent.TimeUnit; public class V2XRoadEventScenario extends AbsV2XScenario implements IMoGoWarningStatusListener { private static final String TAG = "V2XRoadEventScenario"; + public V2XRoadEventScenario() { + setV2XMarker(new V2XRoadEventMarker()); + } @Override public void init(V2XMessageEntity v2XMessageEntity) {