Commit 3219d945 authored by 残页's avatar 残页 Committed by John Wu

Prevent multi animators setting property concurrently

It crashes on Android 5.0 (API 21) platform.
Fix topjohnwu#5793
parent 8a73a160
......@@ -23,6 +23,7 @@ public class ConcealableBottomNavigationView extends BottomNavigationView {
};
private boolean isHidden;
private int lastHeight = -1;
public ConcealableBottomNavigationView(@NonNull Context context) {
this(context, null);
......@@ -41,6 +42,14 @@ public class ConcealableBottomNavigationView extends BottomNavigationView {
}
private void recreateAnimator(int height) {
if (lastHeight == height) return;
lastHeight = height;
// End the current animation before setting a new one
// otherwise it crashes on Android 5.0
StateListAnimator lastAnimator = getStateListAnimator();
if (lastAnimator != null) lastAnimator.jumpToCurrentState();
Animator toHidden = ObjectAnimator.ofFloat(this, "translationY", height);
toHidden.setDuration(175);
toHidden.setInterpolator(new FastOutLinearInInterpolator());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment