[6.1.0][Opt]新增平行驾驶请求中动画效果

This commit is contained in:
chenfufeng
2023-09-20 18:48:13 +08:00
parent 27d96b3896
commit bb4efdd4ae
5 changed files with 57 additions and 2 deletions

View File

@@ -60,9 +60,11 @@ class ParallelDriveView @JvmOverloads constructor(
private lateinit var rootLayout: ConstraintLayout
private lateinit var statusIcon: ImageView
private lateinit var statusIconOuter: ImageView
private lateinit var statusTitle: TextView
private var listener: ClickEventListener? = null
private var animator: ObjectAnimator? = null
private var syncAnimator: ObjectAnimator? = null
init {
LayoutInflater.from(context).inflate(R.layout.view_parallel_drive, this, true)
@@ -79,6 +81,7 @@ class ParallelDriveView @JvmOverloads constructor(
private fun initView() {
rootLayout = findViewById(R.id.parDriveLayout)
statusIcon = findViewById(R.id.ivStatusIcon)
statusIconOuter = findViewById(R.id.ivStatusProgress)
statusTitle = findViewById(R.id.tvAutopilotContent)
rootLayout.setOnClickListener {
when (state) {
@@ -211,6 +214,8 @@ class ParallelDriveView @JvmOverloads constructor(
when (state) {
0 -> {
stopRotateAnimation()
stopSyncAnimation()
statusIconOuter.visibility = GONE
rootLayout.isEnabled = true
rootLayout.alpha = 1f
statusIcon.background =
@@ -222,7 +227,9 @@ class ParallelDriveView @JvmOverloads constructor(
}
APP_REQUESTING -> {
stopSyncAnimation()
rootLayout.isEnabled = true
statusIconOuter.visibility = GONE
rootLayout.alpha = 1f
statusIcon.background =
resources.getDrawable(R.drawable.icon_para_requesting, null)
@@ -234,7 +241,9 @@ class ParallelDriveView @JvmOverloads constructor(
}
AD_REQUESTING -> {
stopSyncAnimation()
rootLayout.isEnabled = false
statusIconOuter.visibility = GONE
rootLayout.alpha = 1f
statusIcon.background =
resources.getDrawable(R.drawable.icon_para_requesting, null)
@@ -250,15 +259,19 @@ class ParallelDriveView @JvmOverloads constructor(
rootLayout.isEnabled = false
rootLayout.alpha = 1f
statusIcon.background =
resources.getDrawable(R.drawable.icon_para_syn, null)
resources.getDrawable(R.drawable.icon_para_syn_inner, null)
statusTitle.setTextColor(Color.parseColor("#FFFFFF"))
statusIcon.alpha = 1f
statusIconOuter.visibility = VISIBLE
startSyncAnimation()
statusTitle.text = context.getString(R.string.parallel_drive_synchronizing)
rootLayout.background = resources.getDrawable(R.drawable.bg_auto_pilot, null)
}
PARALLEL_DRIVING -> {
stopRotateAnimation()
stopSyncAnimation()
statusIconOuter.visibility = GONE
rootLayout.isEnabled = false
rootLayout.alpha = 1f
statusIcon.background =
@@ -272,6 +285,8 @@ class ParallelDriveView @JvmOverloads constructor(
FAILURE -> {
stopRotateAnimation()
stopSyncAnimation()
statusIconOuter.visibility = GONE
rootLayout.isEnabled = false
rootLayout.alpha = 1f
rootLayout.postDelayed({
@@ -287,6 +302,8 @@ class ParallelDriveView @JvmOverloads constructor(
ONE_EXCEPTION -> {
stopRotateAnimation()
stopSyncAnimation()
statusIconOuter.visibility = GONE
rootLayout.isEnabled = false
rootLayout.alpha = 1f
rootLayout.postDelayed({
@@ -302,6 +319,8 @@ class ParallelDriveView @JvmOverloads constructor(
TWO_EXCEPTION -> {
stopRotateAnimation()
stopSyncAnimation()
statusIconOuter.visibility = GONE
rootLayout.isEnabled = false
rootLayout.alpha = 1f
rootLayout.postDelayed({
@@ -317,7 +336,9 @@ class ParallelDriveView @JvmOverloads constructor(
UNAVAILABLE -> {
stopRotateAnimation()
rootLayout.isEnabled = false
stopSyncAnimation()
statusIconOuter.visibility = GONE
rootLayout.isEnabled = true
rootLayout.alpha = 0.4f
statusIcon.background =
resources.getDrawable(R.drawable.icon_autopilot_status, null)
@@ -391,6 +412,28 @@ class ParallelDriveView @JvmOverloads constructor(
it.cancel()
}
}
statusIcon.rotation = 0f
}
@SuppressLint("Recycle")
private fun startSyncAnimation() {
if (syncAnimator == null) {
syncAnimator = ObjectAnimator.ofFloat(statusIconOuter, "rotation", 0f, 360f).apply {
duration = 1500
repeatMode = ValueAnimator.RESTART
repeatCount = ValueAnimator.INFINITE
interpolator = LinearInterpolator()
}
}
syncAnimator?.start()
}
private fun stopSyncAnimation() {
syncAnimator?.let {
if (it.isRunning) {
it.cancel()
}
}
}
override fun onDetachedFromWindow() {

View File

@@ -16,6 +16,18 @@
app:layout_constraintTop_toTopOf="parent"
android:layout_marginStart="72dp"
android:layout_marginTop="56dp"
tools:background="@drawable/icon_para_syn_inner"
/>
<ImageView
android:id="@+id/ivStatusProgress"
android:layout_width="58dp"
android:layout_height="58dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginStart="72dp"
android:layout_marginTop="56dp"
android:background="@drawable/icon_para_syn_outer"
/>
<TextView

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 574 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB