From 63204a14adec8e9fb6b8302acc4cc3536e8e2dac Mon Sep 17 00:00:00 2001 From: zhongchao Date: Thu, 16 Feb 2023 18:37:42 +0800 Subject: [PATCH] [2.13.0-arch-opt]fix bug --- .../sweeper/view/SweeperTrafficDataView.java | 3 - .../hmi/ui/vehicle/SteeringBrakeView.kt | 2 - .../hmi/ui/vehicle/TurnLightViewStatus.kt | 55 +++++++++---------- .../hmi/ui/widget/LimitingVelocityView.kt | 2 + .../res/layout/view_limiting_speed_vr.xml | 3 +- .../eagle/core/function/view/MapBizView.kt | 52 +++++++++++++----- .../CallerChassisLamplightListenerManager.kt | 15 ++--- 7 files changed, 76 insertions(+), 56 deletions(-) diff --git a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/view/SweeperTrafficDataView.java b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/view/SweeperTrafficDataView.java index b8e5c3c370..32db9adef0 100644 --- a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/view/SweeperTrafficDataView.java +++ b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/view/SweeperTrafficDataView.java @@ -94,13 +94,10 @@ public class SweeperTrafficDataView extends ConstraintLayout if (lightSwitch != null) { CallerLogger.INSTANCE.d(TAG, "车辆转向灯:" + lightSwitch.toString()); if (lightSwitch.getNumber()==1){ - CallerVisualAngleManager.INSTANCE.showTurning(true); sweeperTurnSignal.showLeftSignal(); }else if(lightSwitch.getNumber()==2){ - CallerVisualAngleManager.INSTANCE.showTurning(true); sweeperTurnSignal.showRightSignal(); }else{ - CallerVisualAngleManager.INSTANCE.showTurning(false); sweeperTurnSignal.showDirection(); } } diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/vehicle/SteeringBrakeView.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/vehicle/SteeringBrakeView.kt index 604ae04474..f89fe8f773 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/vehicle/SteeringBrakeView.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/vehicle/SteeringBrakeView.kt @@ -81,11 +81,9 @@ class SteeringBrakeView(context: Context, attrs: AttributeSet?) : ConstraintLayo ThreadUtils.runOnUiThread { if (lightSwitch.number == 1 || lightSwitch.number == 2) { isShowTurnLight = true - CallerVisualAngleManager.showTurning(true) brakeView.visibility = View.VISIBLE brakeView.setBrakeLight(0) } else { - CallerVisualAngleManager.showTurning(false) brakeView.visibility = View.GONE isShowTurnLight = false } diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/vehicle/TurnLightViewStatus.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/vehicle/TurnLightViewStatus.kt index 803b0a815e..fd1931ee7f 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/vehicle/TurnLightViewStatus.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/vehicle/TurnLightViewStatus.kt @@ -12,16 +12,10 @@ import android.widget.ImageView import androidx.constraintlayout.widget.ConstraintLayout import chassis.Chassis import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLamplightListener -import com.mogo.eagle.core.function.api.map.angle.Turning import com.mogo.eagle.core.function.call.autopilot.CallerChassisLamplightListenerManager -import com.mogo.eagle.core.function.call.map.CallerVisualAngleManager import com.mogo.eagle.core.function.hmi.R import com.mogo.eagle.core.utilcode.util.ThreadUtils -import kotlinx.android.synthetic.main.view_steering_brake.view.* import kotlinx.android.synthetic.main.view_turn_light_status.view.* -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch /** * @description @@ -40,6 +34,9 @@ open class TurnLightViewStatus @JvmOverloads constructor( } private val visible: Boolean + private var isLeftLight: Boolean = false + private var isRightLight: Boolean = false + private var isDisappear: Boolean = false init { val typedArray = context.obtainStyledAttributes(attrs, R.styleable.TurnLightView) @@ -73,7 +70,6 @@ open class TurnLightViewStatus @JvmOverloads constructor( super.onAutopilotLightSwitchData(lightSwitch) lightSwitch?.let { ThreadUtils.runOnUiThread { - turnLightView.visibility = View.VISIBLE setTurnLight(it) } } @@ -86,27 +82,37 @@ open class TurnLightViewStatus @JvmOverloads constructor( if (!isAttachedToWindow) { return } - GlobalScope.launch(Dispatchers.Main) { - //根据左右进行显示和隐藏,实际要判断每个来的时间和频度 - when (directionLight) { - Chassis.LightSwitch.LIGHT_LEFT -> { //左转向 - CallerVisualAngleManager.showTurning(true) + //根据左右进行显示和隐藏,实际要判断每个来的时间和频度 + when (directionLight.number) { + Chassis.LightSwitch.LIGHT_LEFT_VALUE -> { //左转向 + if (!isLeftLight) { + isLeftLight = true + isRightLight = false + isDisappear = false showNormalAnimation() left_select_image.visibility = View.VISIBLE right_select_image.visibility = View.GONE right_select_image.clearAnimation() setAnimation(left_select_image) } - Chassis.LightSwitch.LIGHT_RIGHT -> { //右转向 - CallerVisualAngleManager.showTurning(true) + } + Chassis.LightSwitch.LIGHT_RIGHT_VALUE -> { //右转向 + if (!isRightLight) { + isRightLight = true + isLeftLight = false + isDisappear = false showNormalAnimation() left_select_image.visibility = View.GONE right_select_image.visibility = View.VISIBLE left_select_image.clearAnimation() setAnimation(right_select_image) } - else -> { //消失 - CallerVisualAngleManager.showTurning(false) + } + Chassis.LightSwitch.LIGHT_NONE_VALUE -> { //消失 + if (!isDisappear) { + isDisappear = true + isLeftLight = false + isRightLight = false animationDisappear() } } @@ -170,10 +176,9 @@ open class TurnLightViewStatus @JvmOverloads constructor( } override fun onAnimationEnd(p0: Animation?) { - if (visible) { + if (!visible) { turn_light_layout.visibility = View.GONE } - stopAnimate() } }) } @@ -182,19 +187,13 @@ open class TurnLightViewStatus @JvmOverloads constructor( private fun setAnimation(imageView: ImageView) { val animationSet = AnimatorSet() val valueAnimator = ObjectAnimator.ofFloat(imageView, "alpha", 0f, 1.0f) - val valueAnimatorDisappare = ObjectAnimator.ofFloat(imageView, "alpha", 1.0f, 0f) + val valueAnimatorDisappear = ObjectAnimator.ofFloat(imageView, "alpha", 1.0f, 0f) valueAnimator.duration = 1000 - valueAnimatorDisappare.duration = 800 + valueAnimatorDisappear.duration = 800 valueAnimator.repeatCount = -1 - valueAnimatorDisappare.repeatCount = -1 - animationSet.playTogether(valueAnimatorDisappare, valueAnimator) + valueAnimatorDisappear.repeatCount = -1 + animationSet.playTogether(valueAnimatorDisappear, valueAnimator) animationSet.start() } - private fun stopAnimate() { - turn_light_layout.clearAnimation() - left_nor_image.clearAnimation() - right_nor_image.clearAnimation() - } - } \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/LimitingVelocityView.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/LimitingVelocityView.kt index ec4155e06c..32406eba70 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/LimitingVelocityView.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/LimitingVelocityView.kt @@ -40,9 +40,11 @@ class LimitingVelocityView constructor( if (limitingVelocity > 0) { this.visibility = View.VISIBLE tvLimitingVelocity.text = "$limitingVelocity" + tvLimitingSource.visibility = View.VISIBLE tvLimitingSource.text = sourceType.name } else { this.visibility = View.GONE + tvLimitingSource.visibility = View.GONE tvLimitingSource.text = "" } } diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_limiting_speed_vr.xml b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_limiting_speed_vr.xml index fb6060c188..0bca4b164a 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_limiting_speed_vr.xml +++ b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_limiting_speed_vr.xml @@ -30,7 +30,6 @@ android:textSize="@dimen/dp_30" android:textStyle="bold" app:layout_constraintLeft_toLeftOf="parent" - app:layout_constraintTop_toBottomOf="@+id/tvLimitingVelocity" - android:visibility="gone" /> + app:layout_constraintTop_toBottomOf="@+id/tvLimitingVelocity" /> \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/view/MapBizView.kt b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/view/MapBizView.kt index 405cb1b4f5..01defbe2ab 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/view/MapBizView.kt +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/view/MapBizView.kt @@ -3,6 +3,7 @@ package com.mogo.eagle.core.function.view import android.content.Context import android.os.Bundle import android.util.AttributeSet +import android.util.Log import androidx.lifecycle.LifecycleObserver import chassis.Chassis import com.mogo.eagle.core.data.map.MogoLocation @@ -11,15 +12,17 @@ import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationWGS84Liste import com.mogo.eagle.core.function.api.setting.IMoGoSkinModeChangeListener import com.mogo.eagle.core.function.call.autopilot.CallerChassisLamplightListenerManager import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationWGS84ListenerManager -import com.mogo.eagle.core.function.call.map.* +import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager +import com.mogo.eagle.core.function.call.map.CallerVisualAngleManager import com.mogo.eagle.core.function.call.setting.CallerSkinModeListenerManager import com.mogo.map.MogoMapView -class MapBizView(context: Context?, attrs: AttributeSet?) : MogoMapView(context, attrs), IMoGoSkinModeChangeListener, - IMoGoChassisLocationWGS84Listener, IMoGoChassisLamplightListener , LifecycleObserver { - - companion object{ +class MapBizView(context: Context?, attrs: AttributeSet?) : MogoMapView(context, attrs), + IMoGoSkinModeChangeListener, + IMoGoChassisLocationWGS84Listener, IMoGoChassisLamplightListener, LifecycleObserver { + + companion object { private const val TAG = "MapBizView" } @@ -34,7 +37,7 @@ class MapBizView(context: Context?, attrs: AttributeSet?) : MogoMapView(context, } - private fun initMapView(){ + private fun initMapView() { map?.uiSettings?.let { //设置所有手势是否可用 it.setAllGesturesEnabled(true) @@ -84,26 +87,47 @@ class MapBizView(context: Context?, attrs: AttributeSet?) : MogoMapView(context, setExtraGPSData(gnssInfo) } + @Volatile + private var isVisualAngleChanged = false + override fun onAutopilotLightSwitchData(lightSwitch: Chassis.LightSwitch?) { super.onAutopilotLightSwitchData(lightSwitch) lightSwitch?.let { when (it.number) { - 1 -> { //左转灯 + Chassis.LightSwitch.LIGHT_LEFT_VALUE -> { //左转灯 CallerVisualAngleManager.showTurning(true) - CallerMapUIServiceManager.getMapUIController()?.setCarLightsType(4, 500) + showTurn(1) } - 2 -> { //右转灯 - CallerVisualAngleManager.showTurning(true) - CallerMapUIServiceManager.getMapUIController()?.setCarLightsType(2, 500) - } - else -> { + Chassis.LightSwitch.LIGHT_RIGHT_VALUE -> { //右转灯 CallerVisualAngleManager.showTurning(false) - CallerMapUIServiceManager.getMapUIController()?.setCarLightsType(3, 500) + showTurn(2) + + } + Chassis.LightSwitch.LIGHT_NONE_VALUE -> { + CallerVisualAngleManager.showTurning(false) + hideTurn() } } } } + private fun showTurn(lightNum: Int) { + if (!isVisualAngleChanged) { + isVisualAngleChanged = true + when (lightNum) { + 1 -> CallerMapUIServiceManager.getMapUIController()?.setCarLightsType(4, 500) + 2 -> CallerMapUIServiceManager.getMapUIController()?.setCarLightsType(2, 500) + } + } + } + + private fun hideTurn() { + if (isVisualAngleChanged) { + isVisualAngleChanged = false + CallerMapUIServiceManager.getMapUIController()?.setCarLightsType(3, 500) + } + } + override fun onDestroy() { // 先取消注册数据,再onDestroy CallerSkinModeListenerManager.removeListener(TAG) diff --git a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/autopilot/CallerChassisLamplightListenerManager.kt b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/autopilot/CallerChassisLamplightListenerManager.kt index e5157806b7..08493422d9 100644 --- a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/autopilot/CallerChassisLamplightListenerManager.kt +++ b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/autopilot/CallerChassisLamplightListenerManager.kt @@ -1,5 +1,6 @@ package com.mogo.eagle.core.function.call.autopilot +import android.util.Log import chassis.Chassis import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLamplightListener import com.mogo.eagle.core.function.call.base.CallerBase @@ -17,24 +18,24 @@ object CallerChassisLamplightListenerManager : CallerBase= 10) { isOnTurnLight = false return turn_light - } else { - turnLightTimes++ - null } + turnLightTimes++ + return null } else { - null + return null } } else { turnLightTimes = 0