From 3219d945f5402b3276b1cc34c7b982687ad83889 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=AE=8B=E9=A1=B5?= <31466456+canyie@users.noreply.github.com> Date: Tue, 31 May 2022 21:24:20 +0800 Subject: [PATCH] Prevent multi animators setting property concurrently It crashes on Android 5.0 (API 21) platform. Fix topjohnwu#5793 --- .../magisk/widget/ConcealableBottomNavigationView.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/src/main/java/com/topjohnwu/magisk/widget/ConcealableBottomNavigationView.java b/app/src/main/java/com/topjohnwu/magisk/widget/ConcealableBottomNavigationView.java index 4690c46fc..c104554d3 100644 --- a/app/src/main/java/com/topjohnwu/magisk/widget/ConcealableBottomNavigationView.java +++ b/app/src/main/java/com/topjohnwu/magisk/widget/ConcealableBottomNavigationView.java @@ -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());