diff options
| author | 2023-04-04 11:25:46 -0700 | |
|---|---|---|
| committer | 2023-04-04 11:37:02 -0700 | |
| commit | 2797d459142ec6d237ca3365ee46d559ca5cdda3 (patch) | |
| tree | 6fe5deaa81875b00818ceecb68ad8bb2847be41d | |
| parent | 9381b26f4d3eb6cd5120c88234f2651b8688f320 (diff) | |
End animation when deleting.
It seems that when we delete and add super quickly, the delete method is
preventing the view from being removed. Instead of removing the view
after the full duration of the animation is complete, we end the
animation to remove the view to begin the next delete.
This actually also makes the reset animation much more succinct when we
long press delete.
Fixes: 276400809
Test: add and delete in pin view very quickly
Change-Id: Ica145faa95a342b10832e355fe04201a9fc78459
| -rw-r--r-- | packages/SystemUI/src/com/android/keyguard/PinShapeNonHintingView.java | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/packages/SystemUI/src/com/android/keyguard/PinShapeNonHintingView.java b/packages/SystemUI/src/com/android/keyguard/PinShapeNonHintingView.java index 6a6e81e9cb46..14810d9baf02 100644 --- a/packages/SystemUI/src/com/android/keyguard/PinShapeNonHintingView.java +++ b/packages/SystemUI/src/com/android/keyguard/PinShapeNonHintingView.java @@ -30,7 +30,6 @@ import android.util.AttributeSet; import android.util.Log; import android.view.View; import android.view.ViewGroup; -import android.view.animation.Animation; import android.widget.ImageView; import android.widget.LinearLayout; @@ -50,7 +49,7 @@ public class PinShapeNonHintingView extends LinearLayout implements PinShapeInpu android.R.attr.textColorPrimary).getDefaultColor(); private int mPosition = 0; private final PinShapeAdapter mPinShapeAdapter; - private Animation mCurrentPlayingAnimation; + private ValueAnimator mValueAnimator = ValueAnimator.ofFloat(1f, 0f); public PinShapeNonHintingView(Context context, AttributeSet attrs) { super(context, attrs); mPinShapeAdapter = new PinShapeAdapter(context); @@ -80,15 +79,17 @@ public class PinShapeNonHintingView extends LinearLayout implements PinShapeInpu Log.e(getClass().getName(), "Trying to delete a non-existent char"); return; } + if (mValueAnimator.isRunning()) { + mValueAnimator.end(); + } mPosition--; ImageView pinDot = (ImageView) getChildAt(mPosition); - ValueAnimator animator = ValueAnimator.ofFloat(1f, 0f); - animator.addUpdateListener(valueAnimator -> { + mValueAnimator.addUpdateListener(valueAnimator -> { float value = (float) valueAnimator.getAnimatedValue(); pinDot.setScaleX(value); pinDot.setScaleY(value); }); - animator.addListener(new AnimatorListenerAdapter() { + mValueAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); @@ -96,11 +97,10 @@ public class PinShapeNonHintingView extends LinearLayout implements PinShapeInpu PinShapeNonHintingView.this, new PinShapeViewTransition()); removeView(pinDot); - mCurrentPlayingAnimation = null; } }); - animator.setDuration(PasswordTextView.DISAPPEAR_DURATION); - animator.start(); + mValueAnimator.setDuration(PasswordTextView.DISAPPEAR_DURATION); + mValueAnimator.start(); } @Override |