Skip to content

Commit f101532

Browse files
afohrmanpekingme
authored andcommitted
[Predictive Back][Search] Fixed UnsupportedOperationException AnimatorSet crash in SearchView.
When navigation icon animation is disabled after the predictive back navigation icon animators are initialized, a strange crash happens in `SearchViewAnimatorSet#updateBackProgress` from the call to `AnimatorSet#setCurrentPlayTime()`, in which the button progress `AnimatorSet` duration is 250 but the total duration is 0. This triggers an [`UnsupportedOperationException`](https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/animation/AnimatorSet.java#928) with the message: `"Error: Play time should always be in between 0 and duration."`. Adding an early return from `SearchViewAnimatorSet#updateBackProgress` when navigation animation is disabled appears to fix the crash. PiperOrigin-RevId: 550885523
1 parent 4c89301 commit f101532

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

lib/java/com/google/android/material/search/SearchViewAnimationHelper.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,11 @@ public void updateBackProgress(@NonNull BackEventCompat backEvent) {
629629
searchView.clearFocusAndHideKeyboard();
630630
}
631631

632+
// Early return if navigation icon animation is disabled.
633+
if (!searchView.isAnimatedNavigationIcon()) {
634+
return;
635+
}
636+
632637
// Start and immediately pause the animator set so we can seek it with setCurrentPlayTime() in
633638
// subsequent updateBackProgress() calls when the progress value changes.
634639
backProgressAnimatorSet = getButtonsProgressAnimator(/* show= */ false);

0 commit comments

Comments
 (0)