[fea]
[m2]
[到站动画]
This commit is contained in:
yangyakun
2025-06-12 11:26:33 +08:00
parent 7f6b160414
commit 5c9d49a92a
3 changed files with 78 additions and 3 deletions

View File

@@ -1,18 +1,28 @@
package com.mogo.och.shuttle.weaknet.passenger.ui.line.arrive
import android.animation.Animator
import android.animation.AnimatorListenerAdapter
import android.animation.ValueAnimator
import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import androidx.constraintlayout.widget.ConstraintLayout
import com.mogo.commons.AbsMogoApplication
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
import com.mogo.och.common.module.manager.loop.BizLoopManager
import com.mogo.och.common.module.utils.ResourcesUtils
import com.mogo.och.data.bean.BusStationBean
import com.mogo.och.shuttle.weaknet.passenger.R
import kotlinx.android.synthetic.main.m2_arrive_view.view.aciv_arrow_left
import kotlinx.android.synthetic.main.m2_arrive_view.view.aciv_arrow_right
import kotlinx.android.synthetic.main.m2_arrive_view.view.aciv_door_left
import kotlinx.android.synthetic.main.m2_arrive_view.view.aciv_door_right
import kotlinx.android.synthetic.main.m2_arrive_view.view.ochtv_arrive_station_value
import me.jessyan.autosize.utils.AutoSizeUtils
class ArrivedView : ConstraintLayout {
private val TAG = "EmptyView"
private val TAG = "ArrivedView"
constructor(context: Context) : super(context)
@@ -22,6 +32,50 @@ class ArrivedView : ConstraintLayout {
constructor(context: Context, attributeSet: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(context, attributeSet, defStyleAttr, defStyleRes)
val marginMax = AutoSizeUtils.dp2px(AbsMogoApplication.getApp(),-137f)
val marginMin = AutoSizeUtils.dp2px(AbsMogoApplication.getApp(),-55f)
val animatorArrow = ValueAnimator.ofInt(0, 30).apply {
duration = 500
repeatMode = ValueAnimator.REVERSE
repeatCount = -1
addUpdateListener { animation ->
val index = animation.animatedValue as Int
val paramsLeft = aciv_arrow_left.layoutParams as LayoutParams
paramsLeft.marginEnd = index
aciv_arrow_left.layoutParams = paramsLeft
val paramsRight = aciv_arrow_right.layoutParams as LayoutParams
paramsRight.marginStart = index
aciv_arrow_right.layoutParams = paramsRight
}
}
val animator = ValueAnimator.ofInt(marginMax, marginMin).apply {
duration = 500
addUpdateListener { animation ->
val index = animation.animatedValue as Int
val paramsLeft = aciv_door_left.layoutParams as LayoutParams
paramsLeft.marginEnd = index
aciv_door_left.layoutParams = paramsLeft
val paramsRight = aciv_door_right.layoutParams as LayoutParams
paramsRight.marginStart = index
aciv_door_right.layoutParams = paramsRight
if(index==-100){
aciv_arrow_left.visibility = VISIBLE
aciv_arrow_right.visibility = VISIBLE
}
}
addListener(object : AnimatorListenerAdapter() {
override fun onAnimationEnd(animation: Animator) {
animatorArrow.start()
CallerLogger.d(TAG,"动画结束了")
}
})
}
private fun initView() {
LayoutInflater.from(context).inflate(R.layout.m2_arrive_view, this, true)
@@ -36,6 +90,25 @@ class ArrivedView : ConstraintLayout {
override fun onVisibilityAggregated(isVisible: Boolean) {
super.onVisibilityAggregated(isVisible)
CallerLogger.d(TAG,"isVisible:${isVisible}")
if(isVisible) {
if(!animator.isRunning){
animator.start()
}
}else{
animator.cancel()
val paramsLeft = aciv_door_left.layoutParams as LayoutParams
paramsLeft.marginEnd =marginMax
aciv_door_left.layoutParams = paramsLeft
val paramsRight = aciv_door_right.layoutParams as LayoutParams
paramsRight.marginStart = marginMax
aciv_door_right.layoutParams = paramsRight
aciv_arrow_left.visibility = GONE
aciv_arrow_right.visibility = GONE
animatorArrow.cancel()
}
}
fun setArrivedStation(busStationBean: BusStationBean) {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

View File

@@ -69,11 +69,12 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/aciv_doorway"
android:layout_marginBottom="@dimen/dp_20"
android:layout_marginEnd="-58dp"
android:layout_marginEnd="-137dp"
android:layout_width="@dimen/dp_146"
android:layout_height="@dimen/dp_273"/>
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/aciv_arrow_left"
android:src="@drawable/b2_arrive_door_left_arrow"
app:layout_constraintBottom_toBottomOf="@+id/aciv_door_left"
app:layout_constraintEnd_toStartOf="@+id/aciv_door_left"
@@ -89,11 +90,12 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/aciv_doorway"
android:layout_marginBottom="@dimen/dp_20"
android:layout_marginStart="-40dp"
android:layout_marginStart="-137dp"
android:layout_width="@dimen/dp_146"
android:layout_height="@dimen/dp_273"/>
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/aciv_arrow_right"
android:src="@drawable/b2_arrive_door_right_arrow"
app:layout_constraintBottom_toBottomOf="@+id/aciv_door_right"
app:layout_constraintStart_toEndOf="@+id/aciv_door_right"