[6.1.0][Opt]新增平行驾驶请求中动画效果
This commit is contained in:
@@ -60,9 +60,11 @@ class ParallelDriveView @JvmOverloads constructor(
|
|||||||
|
|
||||||
private lateinit var rootLayout: ConstraintLayout
|
private lateinit var rootLayout: ConstraintLayout
|
||||||
private lateinit var statusIcon: ImageView
|
private lateinit var statusIcon: ImageView
|
||||||
|
private lateinit var statusIconOuter: ImageView
|
||||||
private lateinit var statusTitle: TextView
|
private lateinit var statusTitle: TextView
|
||||||
private var listener: ClickEventListener? = null
|
private var listener: ClickEventListener? = null
|
||||||
private var animator: ObjectAnimator? = null
|
private var animator: ObjectAnimator? = null
|
||||||
|
private var syncAnimator: ObjectAnimator? = null
|
||||||
|
|
||||||
init {
|
init {
|
||||||
LayoutInflater.from(context).inflate(R.layout.view_parallel_drive, this, true)
|
LayoutInflater.from(context).inflate(R.layout.view_parallel_drive, this, true)
|
||||||
@@ -79,6 +81,7 @@ class ParallelDriveView @JvmOverloads constructor(
|
|||||||
private fun initView() {
|
private fun initView() {
|
||||||
rootLayout = findViewById(R.id.parDriveLayout)
|
rootLayout = findViewById(R.id.parDriveLayout)
|
||||||
statusIcon = findViewById(R.id.ivStatusIcon)
|
statusIcon = findViewById(R.id.ivStatusIcon)
|
||||||
|
statusIconOuter = findViewById(R.id.ivStatusProgress)
|
||||||
statusTitle = findViewById(R.id.tvAutopilotContent)
|
statusTitle = findViewById(R.id.tvAutopilotContent)
|
||||||
rootLayout.setOnClickListener {
|
rootLayout.setOnClickListener {
|
||||||
when (state) {
|
when (state) {
|
||||||
@@ -211,6 +214,8 @@ class ParallelDriveView @JvmOverloads constructor(
|
|||||||
when (state) {
|
when (state) {
|
||||||
0 -> {
|
0 -> {
|
||||||
stopRotateAnimation()
|
stopRotateAnimation()
|
||||||
|
stopSyncAnimation()
|
||||||
|
statusIconOuter.visibility = GONE
|
||||||
rootLayout.isEnabled = true
|
rootLayout.isEnabled = true
|
||||||
rootLayout.alpha = 1f
|
rootLayout.alpha = 1f
|
||||||
statusIcon.background =
|
statusIcon.background =
|
||||||
@@ -222,7 +227,9 @@ class ParallelDriveView @JvmOverloads constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
APP_REQUESTING -> {
|
APP_REQUESTING -> {
|
||||||
|
stopSyncAnimation()
|
||||||
rootLayout.isEnabled = true
|
rootLayout.isEnabled = true
|
||||||
|
statusIconOuter.visibility = GONE
|
||||||
rootLayout.alpha = 1f
|
rootLayout.alpha = 1f
|
||||||
statusIcon.background =
|
statusIcon.background =
|
||||||
resources.getDrawable(R.drawable.icon_para_requesting, null)
|
resources.getDrawable(R.drawable.icon_para_requesting, null)
|
||||||
@@ -234,7 +241,9 @@ class ParallelDriveView @JvmOverloads constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
AD_REQUESTING -> {
|
AD_REQUESTING -> {
|
||||||
|
stopSyncAnimation()
|
||||||
rootLayout.isEnabled = false
|
rootLayout.isEnabled = false
|
||||||
|
statusIconOuter.visibility = GONE
|
||||||
rootLayout.alpha = 1f
|
rootLayout.alpha = 1f
|
||||||
statusIcon.background =
|
statusIcon.background =
|
||||||
resources.getDrawable(R.drawable.icon_para_requesting, null)
|
resources.getDrawable(R.drawable.icon_para_requesting, null)
|
||||||
@@ -250,15 +259,19 @@ class ParallelDriveView @JvmOverloads constructor(
|
|||||||
rootLayout.isEnabled = false
|
rootLayout.isEnabled = false
|
||||||
rootLayout.alpha = 1f
|
rootLayout.alpha = 1f
|
||||||
statusIcon.background =
|
statusIcon.background =
|
||||||
resources.getDrawable(R.drawable.icon_para_syn, null)
|
resources.getDrawable(R.drawable.icon_para_syn_inner, null)
|
||||||
statusTitle.setTextColor(Color.parseColor("#FFFFFF"))
|
statusTitle.setTextColor(Color.parseColor("#FFFFFF"))
|
||||||
statusIcon.alpha = 1f
|
statusIcon.alpha = 1f
|
||||||
|
statusIconOuter.visibility = VISIBLE
|
||||||
|
startSyncAnimation()
|
||||||
statusTitle.text = context.getString(R.string.parallel_drive_synchronizing)
|
statusTitle.text = context.getString(R.string.parallel_drive_synchronizing)
|
||||||
rootLayout.background = resources.getDrawable(R.drawable.bg_auto_pilot, null)
|
rootLayout.background = resources.getDrawable(R.drawable.bg_auto_pilot, null)
|
||||||
}
|
}
|
||||||
|
|
||||||
PARALLEL_DRIVING -> {
|
PARALLEL_DRIVING -> {
|
||||||
stopRotateAnimation()
|
stopRotateAnimation()
|
||||||
|
stopSyncAnimation()
|
||||||
|
statusIconOuter.visibility = GONE
|
||||||
rootLayout.isEnabled = false
|
rootLayout.isEnabled = false
|
||||||
rootLayout.alpha = 1f
|
rootLayout.alpha = 1f
|
||||||
statusIcon.background =
|
statusIcon.background =
|
||||||
@@ -272,6 +285,8 @@ class ParallelDriveView @JvmOverloads constructor(
|
|||||||
|
|
||||||
FAILURE -> {
|
FAILURE -> {
|
||||||
stopRotateAnimation()
|
stopRotateAnimation()
|
||||||
|
stopSyncAnimation()
|
||||||
|
statusIconOuter.visibility = GONE
|
||||||
rootLayout.isEnabled = false
|
rootLayout.isEnabled = false
|
||||||
rootLayout.alpha = 1f
|
rootLayout.alpha = 1f
|
||||||
rootLayout.postDelayed({
|
rootLayout.postDelayed({
|
||||||
@@ -287,6 +302,8 @@ class ParallelDriveView @JvmOverloads constructor(
|
|||||||
|
|
||||||
ONE_EXCEPTION -> {
|
ONE_EXCEPTION -> {
|
||||||
stopRotateAnimation()
|
stopRotateAnimation()
|
||||||
|
stopSyncAnimation()
|
||||||
|
statusIconOuter.visibility = GONE
|
||||||
rootLayout.isEnabled = false
|
rootLayout.isEnabled = false
|
||||||
rootLayout.alpha = 1f
|
rootLayout.alpha = 1f
|
||||||
rootLayout.postDelayed({
|
rootLayout.postDelayed({
|
||||||
@@ -302,6 +319,8 @@ class ParallelDriveView @JvmOverloads constructor(
|
|||||||
|
|
||||||
TWO_EXCEPTION -> {
|
TWO_EXCEPTION -> {
|
||||||
stopRotateAnimation()
|
stopRotateAnimation()
|
||||||
|
stopSyncAnimation()
|
||||||
|
statusIconOuter.visibility = GONE
|
||||||
rootLayout.isEnabled = false
|
rootLayout.isEnabled = false
|
||||||
rootLayout.alpha = 1f
|
rootLayout.alpha = 1f
|
||||||
rootLayout.postDelayed({
|
rootLayout.postDelayed({
|
||||||
@@ -317,7 +336,9 @@ class ParallelDriveView @JvmOverloads constructor(
|
|||||||
|
|
||||||
UNAVAILABLE -> {
|
UNAVAILABLE -> {
|
||||||
stopRotateAnimation()
|
stopRotateAnimation()
|
||||||
rootLayout.isEnabled = false
|
stopSyncAnimation()
|
||||||
|
statusIconOuter.visibility = GONE
|
||||||
|
rootLayout.isEnabled = true
|
||||||
rootLayout.alpha = 0.4f
|
rootLayout.alpha = 0.4f
|
||||||
statusIcon.background =
|
statusIcon.background =
|
||||||
resources.getDrawable(R.drawable.icon_autopilot_status, null)
|
resources.getDrawable(R.drawable.icon_autopilot_status, null)
|
||||||
@@ -391,6 +412,28 @@ class ParallelDriveView @JvmOverloads constructor(
|
|||||||
it.cancel()
|
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() {
|
override fun onDetachedFromWindow() {
|
||||||
|
|||||||
@@ -16,6 +16,18 @@
|
|||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
android:layout_marginStart="72dp"
|
android:layout_marginStart="72dp"
|
||||||
android:layout_marginTop="56dp"
|
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
|
<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 |
Reference in New Issue
Block a user