[6.1.0][Opt新增平行驾驶请求中动画效果
This commit is contained in:
@@ -1,16 +1,18 @@
|
||||
package com.mogo.eagle.core.function.hmi.ui.widget
|
||||
|
||||
import android.animation.ObjectAnimator
|
||||
import android.animation.ValueAnimator
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.graphics.Color
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.view.animation.LinearInterpolator
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig
|
||||
import com.mogo.commons.voice.AIAssist
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotActionsListener
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoParallelDrivingActionsListener
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoParallelDrivingStatusListener
|
||||
@@ -22,7 +24,6 @@ import com.mogo.eagle.core.function.hmi.R
|
||||
import com.mogo.eagle.core.utilcode.util.ThreadUtils
|
||||
import com.mogo.eagle.core.utilcode.util.ToastUtils
|
||||
import com.zhjt.mogo.adas.data.bean.UnableLaunchReason
|
||||
import com.zhjt.mogo.adas.data.bean.UnableLaunchReason.SourceType
|
||||
import mogo.yycp.paralleldriving.protocol.ParallelDrivingRequest.ParallelRequest
|
||||
import mogo.yycp.paralleldriving.protocol.ParallelTaskProcessNoticeOuterClass
|
||||
|
||||
@@ -50,6 +51,7 @@ class ParallelDriveView @JvmOverloads constructor(
|
||||
//1:ready, 2:自动驾驶中, 7:平行驾驶中
|
||||
@Volatile
|
||||
private var autopilotState: Int = 1
|
||||
|
||||
@Volatile
|
||||
private var isAutoDriving: Boolean = false
|
||||
|
||||
@@ -60,6 +62,7 @@ class ParallelDriveView @JvmOverloads constructor(
|
||||
private lateinit var statusIcon: ImageView
|
||||
private lateinit var statusTitle: TextView
|
||||
private var listener: ClickEventListener? = null
|
||||
private var animator: ObjectAnimator? = null
|
||||
|
||||
init {
|
||||
LayoutInflater.from(context).inflate(R.layout.view_parallel_drive, this, true)
|
||||
@@ -115,11 +118,13 @@ class ParallelDriveView @JvmOverloads constructor(
|
||||
}, ThreadUtils.MODE.QUEUE)
|
||||
}
|
||||
}
|
||||
|
||||
2 -> {
|
||||
if (this.autopilotState != state) {
|
||||
isAutoDriving = true
|
||||
}
|
||||
}
|
||||
|
||||
else -> {
|
||||
if (this.autopilotState != state) {
|
||||
isAutoDriving = false
|
||||
@@ -161,30 +166,37 @@ class ParallelDriveView @JvmOverloads constructor(
|
||||
state = SYNCHRONIZING
|
||||
updateUI(SYNCHRONIZING)
|
||||
}
|
||||
|
||||
"EXCEPTION_EXIT_SYNC" -> {// 同步异常结束
|
||||
state = ONE_EXCEPTION
|
||||
updateUI(ONE_EXCEPTION)
|
||||
}
|
||||
|
||||
"TASK_REJECTED" -> {// 任务已被拒绝
|
||||
state = FAILURE
|
||||
updateUI(FAILURE)
|
||||
AIAssist.getInstance(context).speakTTSVoice("请求已被拒绝")
|
||||
}
|
||||
|
||||
"PARALLEL_EXCEPTION_MANUAL_DRIVING" -> {// 异常请人工驾驶
|
||||
state = TWO_EXCEPTION
|
||||
updateUI(TWO_EXCEPTION)
|
||||
}
|
||||
|
||||
"EXCEPTION_EXIT_PARALLEL_DRIVING" -> {// 平行驾驶异常结束
|
||||
state = ONE_EXCEPTION
|
||||
updateUI(ONE_EXCEPTION)
|
||||
}
|
||||
|
||||
"EXIT_SYNC" -> {// 同步结束
|
||||
checkAvailableAndUpdateUI()
|
||||
}
|
||||
|
||||
"UNABLE_TAKEOVER" -> {// 无法接管
|
||||
state = ONE_EXCEPTION
|
||||
updateUI(ONE_EXCEPTION)
|
||||
}
|
||||
|
||||
"VEHICLE_IN_TROUBLE_PARALLEL_REQUESTED" -> {// 车辆遇困请求平行驾驶
|
||||
state = AD_REQUESTING
|
||||
updateUI(AD_REQUESTING)
|
||||
@@ -198,6 +210,7 @@ class ParallelDriveView @JvmOverloads constructor(
|
||||
private fun updateUI(state: Int) {
|
||||
when (state) {
|
||||
0 -> {
|
||||
stopRotateAnimation()
|
||||
rootLayout.isEnabled = true
|
||||
rootLayout.alpha = 1f
|
||||
statusIcon.background =
|
||||
@@ -215,6 +228,7 @@ class ParallelDriveView @JvmOverloads constructor(
|
||||
resources.getDrawable(R.drawable.icon_para_requesting, null)
|
||||
statusTitle.setTextColor(Color.parseColor("#FFFFFF"))
|
||||
statusIcon.alpha = 1f
|
||||
startRotateAnimation()
|
||||
statusTitle.text = context.getString(R.string.parallel_drive_requesting)
|
||||
rootLayout.background = resources.getDrawable(R.drawable.bg_auto_pilot, null)
|
||||
}
|
||||
@@ -226,11 +240,13 @@ class ParallelDriveView @JvmOverloads constructor(
|
||||
resources.getDrawable(R.drawable.icon_para_requesting, null)
|
||||
statusTitle.setTextColor(Color.parseColor("#FFFFFF"))
|
||||
statusIcon.alpha = 1f
|
||||
startRotateAnimation()
|
||||
statusTitle.text = context.getString(R.string.parallel_drive_requesting)
|
||||
rootLayout.background = resources.getDrawable(R.drawable.bg_auto_pilot, null)
|
||||
}
|
||||
|
||||
SYNCHRONIZING -> {
|
||||
stopRotateAnimation()
|
||||
rootLayout.isEnabled = false
|
||||
rootLayout.alpha = 1f
|
||||
statusIcon.background =
|
||||
@@ -242,6 +258,7 @@ class ParallelDriveView @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
PARALLEL_DRIVING -> {
|
||||
stopRotateAnimation()
|
||||
rootLayout.isEnabled = false
|
||||
rootLayout.alpha = 1f
|
||||
statusIcon.background =
|
||||
@@ -254,6 +271,7 @@ class ParallelDriveView @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
FAILURE -> {
|
||||
stopRotateAnimation()
|
||||
rootLayout.isEnabled = false
|
||||
rootLayout.alpha = 1f
|
||||
rootLayout.postDelayed({
|
||||
@@ -268,6 +286,7 @@ class ParallelDriveView @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
ONE_EXCEPTION -> {
|
||||
stopRotateAnimation()
|
||||
rootLayout.isEnabled = false
|
||||
rootLayout.alpha = 1f
|
||||
rootLayout.postDelayed({
|
||||
@@ -282,6 +301,7 @@ class ParallelDriveView @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
TWO_EXCEPTION -> {
|
||||
stopRotateAnimation()
|
||||
rootLayout.isEnabled = false
|
||||
rootLayout.alpha = 1f
|
||||
rootLayout.postDelayed({
|
||||
@@ -296,6 +316,7 @@ class ParallelDriveView @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
UNAVAILABLE -> {
|
||||
stopRotateAnimation()
|
||||
rootLayout.isEnabled = false
|
||||
rootLayout.alpha = 0.4f
|
||||
statusIcon.background =
|
||||
@@ -351,6 +372,27 @@ class ParallelDriveView @JvmOverloads constructor(
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("Recycle")
|
||||
private fun startRotateAnimation() {
|
||||
if (animator == null) {
|
||||
animator = ObjectAnimator.ofFloat(statusIcon, "rotation", 0f, 360f).apply {
|
||||
duration = 1500
|
||||
repeatMode = ValueAnimator.RESTART
|
||||
repeatCount = ValueAnimator.INFINITE
|
||||
interpolator = LinearInterpolator()
|
||||
}
|
||||
}
|
||||
animator?.start()
|
||||
}
|
||||
|
||||
private fun stopRotateAnimation() {
|
||||
animator?.let {
|
||||
if (it.isRunning) {
|
||||
it.cancel()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow()
|
||||
CallerAutoPilotStatusListenerManager.removeListener(TAG)
|
||||
|
||||
Reference in New Issue
Block a user