ADD week 5
This commit is contained in:
@@ -0,0 +1,599 @@
|
||||
package com.google.android.material.search;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.animation.AnimatorSet;
|
||||
import android.animation.TimeInterpolator;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.view.Menu;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.EditText;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.TextView;
|
||||
import androidx.activity.BackEventCompat;
|
||||
import androidx.appcompat.graphics.drawable.DrawerArrowDrawable;
|
||||
import androidx.appcompat.widget.ActionMenuView;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.core.graphics.drawable.DrawableCompat;
|
||||
import androidx.core.view.MarginLayoutParamsCompat;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import com.google.android.material.animation.AnimationUtils;
|
||||
import com.google.android.material.internal.ClippableRoundedCornerLayout;
|
||||
import com.google.android.material.internal.FadeThroughDrawable;
|
||||
import com.google.android.material.internal.FadeThroughUpdateListener;
|
||||
import com.google.android.material.internal.MultiViewUpdateListener;
|
||||
import com.google.android.material.internal.RectEvaluator;
|
||||
import com.google.android.material.internal.ReversableAnimatedValueInterpolator;
|
||||
import com.google.android.material.internal.ToolbarUtils;
|
||||
import com.google.android.material.internal.TouchObserverFrameLayout;
|
||||
import com.google.android.material.internal.ViewUtils;
|
||||
import com.google.android.material.motion.MaterialMainContainerBackHelper;
|
||||
import com.google.android.material.search.SearchView;
|
||||
import java.util.Objects;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class SearchViewAnimationHelper {
|
||||
private static final float CONTENT_FROM_SCALE = 0.95f;
|
||||
private static final long HIDE_CLEAR_BUTTON_ALPHA_DURATION_MS = 42;
|
||||
private static final long HIDE_CLEAR_BUTTON_ALPHA_START_DELAY_MS = 0;
|
||||
private static final long HIDE_CONTENT_ALPHA_DURATION_MS = 83;
|
||||
private static final long HIDE_CONTENT_ALPHA_START_DELAY_MS = 0;
|
||||
private static final long HIDE_CONTENT_SCALE_DURATION_MS = 250;
|
||||
private static final long HIDE_DURATION_MS = 250;
|
||||
private static final long HIDE_TRANSLATE_DURATION_MS = 300;
|
||||
private static final long SHOW_CLEAR_BUTTON_ALPHA_DURATION_MS = 50;
|
||||
private static final long SHOW_CLEAR_BUTTON_ALPHA_START_DELAY_MS = 250;
|
||||
private static final long SHOW_CONTENT_ALPHA_DURATION_MS = 150;
|
||||
private static final long SHOW_CONTENT_ALPHA_START_DELAY_MS = 75;
|
||||
private static final long SHOW_CONTENT_SCALE_DURATION_MS = 300;
|
||||
private static final long SHOW_DURATION_MS = 300;
|
||||
private static final long SHOW_TRANSLATE_DURATION_MS = 350;
|
||||
private static final long SHOW_TRANSLATE_KEYBOARD_START_DELAY_MS = 150;
|
||||
private final MaterialMainContainerBackHelper backHelper;
|
||||
private AnimatorSet backProgressAnimatorSet;
|
||||
private final ImageButton clearButton;
|
||||
private final TouchObserverFrameLayout contentContainer;
|
||||
private final View divider;
|
||||
private final Toolbar dummyToolbar;
|
||||
private final EditText editText;
|
||||
private final FrameLayout headerContainer;
|
||||
private final ClippableRoundedCornerLayout rootView;
|
||||
private final View scrim;
|
||||
private SearchBar searchBar;
|
||||
private final TextView searchPrefix;
|
||||
private final SearchView searchView;
|
||||
private final Toolbar toolbar;
|
||||
private final FrameLayout toolbarContainer;
|
||||
|
||||
MaterialMainContainerBackHelper getBackHelper() {
|
||||
return this.backHelper;
|
||||
}
|
||||
|
||||
void setSearchBar(SearchBar searchBar) {
|
||||
this.searchBar = searchBar;
|
||||
}
|
||||
|
||||
SearchViewAnimationHelper(SearchView searchView) {
|
||||
this.searchView = searchView;
|
||||
this.scrim = searchView.scrim;
|
||||
ClippableRoundedCornerLayout clippableRoundedCornerLayout = searchView.rootView;
|
||||
this.rootView = clippableRoundedCornerLayout;
|
||||
this.headerContainer = searchView.headerContainer;
|
||||
this.toolbarContainer = searchView.toolbarContainer;
|
||||
this.toolbar = searchView.toolbar;
|
||||
this.dummyToolbar = searchView.dummyToolbar;
|
||||
this.searchPrefix = searchView.searchPrefix;
|
||||
this.editText = searchView.editText;
|
||||
this.clearButton = searchView.clearButton;
|
||||
this.divider = searchView.divider;
|
||||
this.contentContainer = searchView.contentContainer;
|
||||
this.backHelper = new MaterialMainContainerBackHelper(clippableRoundedCornerLayout);
|
||||
}
|
||||
|
||||
void show() {
|
||||
if (this.searchBar != null) {
|
||||
startShowAnimationExpand();
|
||||
} else {
|
||||
startShowAnimationTranslate();
|
||||
}
|
||||
}
|
||||
|
||||
AnimatorSet hide() {
|
||||
if (this.searchBar != null) {
|
||||
return startHideAnimationCollapse();
|
||||
}
|
||||
return startHideAnimationTranslate();
|
||||
}
|
||||
|
||||
private void startShowAnimationExpand() {
|
||||
if (this.searchView.isAdjustNothingSoftInputMode()) {
|
||||
this.searchView.requestFocusAndShowKeyboardIfNeeded();
|
||||
}
|
||||
this.searchView.setTransitionState(SearchView.TransitionState.SHOWING);
|
||||
setUpDummyToolbarIfNeeded();
|
||||
this.editText.setText(this.searchBar.getText());
|
||||
EditText editText = this.editText;
|
||||
editText.setSelection(editText.getText().length());
|
||||
this.rootView.setVisibility(4);
|
||||
this.rootView.post(new Runnable() { // from class: com.google.android.material.search.SearchViewAnimationHelper$$ExternalSyntheticLambda5
|
||||
@Override // java.lang.Runnable
|
||||
public final void run() {
|
||||
SearchViewAnimationHelper.this.m258x94743afc();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/* renamed from: lambda$startShowAnimationExpand$0$com-google-android-material-search-SearchViewAnimationHelper, reason: not valid java name */
|
||||
/* synthetic */ void m258x94743afc() {
|
||||
AnimatorSet expandCollapseAnimatorSet = getExpandCollapseAnimatorSet(true);
|
||||
expandCollapseAnimatorSet.addListener(new AnimatorListenerAdapter() { // from class: com.google.android.material.search.SearchViewAnimationHelper.1
|
||||
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
|
||||
public void onAnimationStart(Animator animator) {
|
||||
SearchViewAnimationHelper.this.rootView.setVisibility(0);
|
||||
SearchViewAnimationHelper.this.searchBar.stopOnLoadAnimation();
|
||||
}
|
||||
|
||||
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
|
||||
public void onAnimationEnd(Animator animator) {
|
||||
if (!SearchViewAnimationHelper.this.searchView.isAdjustNothingSoftInputMode()) {
|
||||
SearchViewAnimationHelper.this.searchView.requestFocusAndShowKeyboardIfNeeded();
|
||||
}
|
||||
SearchViewAnimationHelper.this.searchView.setTransitionState(SearchView.TransitionState.SHOWN);
|
||||
}
|
||||
});
|
||||
expandCollapseAnimatorSet.start();
|
||||
}
|
||||
|
||||
private AnimatorSet startHideAnimationCollapse() {
|
||||
if (this.searchView.isAdjustNothingSoftInputMode()) {
|
||||
this.searchView.clearFocusAndHideKeyboard();
|
||||
}
|
||||
AnimatorSet expandCollapseAnimatorSet = getExpandCollapseAnimatorSet(false);
|
||||
expandCollapseAnimatorSet.addListener(new AnimatorListenerAdapter() { // from class: com.google.android.material.search.SearchViewAnimationHelper.2
|
||||
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
|
||||
public void onAnimationStart(Animator animator) {
|
||||
SearchViewAnimationHelper.this.searchView.setTransitionState(SearchView.TransitionState.HIDING);
|
||||
}
|
||||
|
||||
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
|
||||
public void onAnimationEnd(Animator animator) {
|
||||
SearchViewAnimationHelper.this.rootView.setVisibility(8);
|
||||
if (!SearchViewAnimationHelper.this.searchView.isAdjustNothingSoftInputMode()) {
|
||||
SearchViewAnimationHelper.this.searchView.clearFocusAndHideKeyboard();
|
||||
}
|
||||
SearchViewAnimationHelper.this.searchView.setTransitionState(SearchView.TransitionState.HIDDEN);
|
||||
}
|
||||
});
|
||||
expandCollapseAnimatorSet.start();
|
||||
return expandCollapseAnimatorSet;
|
||||
}
|
||||
|
||||
private void startShowAnimationTranslate() {
|
||||
if (this.searchView.isAdjustNothingSoftInputMode()) {
|
||||
final SearchView searchView = this.searchView;
|
||||
Objects.requireNonNull(searchView);
|
||||
searchView.postDelayed(new Runnable() { // from class: com.google.android.material.search.SearchViewAnimationHelper$$ExternalSyntheticLambda6
|
||||
@Override // java.lang.Runnable
|
||||
public final void run() {
|
||||
SearchView.this.requestFocusAndShowKeyboardIfNeeded();
|
||||
}
|
||||
}, 150L);
|
||||
}
|
||||
this.rootView.setVisibility(4);
|
||||
this.rootView.post(new Runnable() { // from class: com.google.android.material.search.SearchViewAnimationHelper$$ExternalSyntheticLambda7
|
||||
@Override // java.lang.Runnable
|
||||
public final void run() {
|
||||
SearchViewAnimationHelper.this.m259x4df249eb();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/* renamed from: lambda$startShowAnimationTranslate$1$com-google-android-material-search-SearchViewAnimationHelper, reason: not valid java name */
|
||||
/* synthetic */ void m259x4df249eb() {
|
||||
this.rootView.setTranslationY(r0.getHeight());
|
||||
AnimatorSet translateAnimatorSet = getTranslateAnimatorSet(true);
|
||||
translateAnimatorSet.addListener(new AnimatorListenerAdapter() { // from class: com.google.android.material.search.SearchViewAnimationHelper.3
|
||||
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
|
||||
public void onAnimationStart(Animator animator) {
|
||||
SearchViewAnimationHelper.this.rootView.setVisibility(0);
|
||||
SearchViewAnimationHelper.this.searchView.setTransitionState(SearchView.TransitionState.SHOWING);
|
||||
}
|
||||
|
||||
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
|
||||
public void onAnimationEnd(Animator animator) {
|
||||
if (!SearchViewAnimationHelper.this.searchView.isAdjustNothingSoftInputMode()) {
|
||||
SearchViewAnimationHelper.this.searchView.requestFocusAndShowKeyboardIfNeeded();
|
||||
}
|
||||
SearchViewAnimationHelper.this.searchView.setTransitionState(SearchView.TransitionState.SHOWN);
|
||||
}
|
||||
});
|
||||
translateAnimatorSet.start();
|
||||
}
|
||||
|
||||
private AnimatorSet startHideAnimationTranslate() {
|
||||
if (this.searchView.isAdjustNothingSoftInputMode()) {
|
||||
this.searchView.clearFocusAndHideKeyboard();
|
||||
}
|
||||
AnimatorSet translateAnimatorSet = getTranslateAnimatorSet(false);
|
||||
translateAnimatorSet.addListener(new AnimatorListenerAdapter() { // from class: com.google.android.material.search.SearchViewAnimationHelper.4
|
||||
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
|
||||
public void onAnimationStart(Animator animator) {
|
||||
SearchViewAnimationHelper.this.searchView.setTransitionState(SearchView.TransitionState.HIDING);
|
||||
}
|
||||
|
||||
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
|
||||
public void onAnimationEnd(Animator animator) {
|
||||
SearchViewAnimationHelper.this.rootView.setVisibility(8);
|
||||
if (!SearchViewAnimationHelper.this.searchView.isAdjustNothingSoftInputMode()) {
|
||||
SearchViewAnimationHelper.this.searchView.clearFocusAndHideKeyboard();
|
||||
}
|
||||
SearchViewAnimationHelper.this.searchView.setTransitionState(SearchView.TransitionState.HIDDEN);
|
||||
}
|
||||
});
|
||||
translateAnimatorSet.start();
|
||||
return translateAnimatorSet;
|
||||
}
|
||||
|
||||
private AnimatorSet getTranslateAnimatorSet(boolean z) {
|
||||
AnimatorSet animatorSet = new AnimatorSet();
|
||||
animatorSet.playTogether(getTranslationYAnimator());
|
||||
addBackButtonProgressAnimatorIfNeeded(animatorSet);
|
||||
animatorSet.setInterpolator(ReversableAnimatedValueInterpolator.of(z, AnimationUtils.FAST_OUT_SLOW_IN_INTERPOLATOR));
|
||||
animatorSet.setDuration(z ? SHOW_TRANSLATE_DURATION_MS : 300L);
|
||||
return animatorSet;
|
||||
}
|
||||
|
||||
private Animator getTranslationYAnimator() {
|
||||
ValueAnimator ofFloat = ValueAnimator.ofFloat(this.rootView.getHeight(), 0.0f);
|
||||
ofFloat.addUpdateListener(MultiViewUpdateListener.translationYListener(this.rootView));
|
||||
return ofFloat;
|
||||
}
|
||||
|
||||
private AnimatorSet getExpandCollapseAnimatorSet(final boolean z) {
|
||||
AnimatorSet animatorSet = new AnimatorSet();
|
||||
if (this.backProgressAnimatorSet == null) {
|
||||
animatorSet.playTogether(getButtonsProgressAnimator(z), getButtonsTranslationAnimator(z));
|
||||
}
|
||||
animatorSet.playTogether(getScrimAlphaAnimator(z), getRootViewAnimator(z), getClearButtonAnimator(z), getContentAnimator(z), getHeaderContainerAnimator(z), getDummyToolbarAnimator(z), getActionMenuViewsAlphaAnimator(z), getEditTextAnimator(z), getSearchPrefixAnimator(z));
|
||||
animatorSet.addListener(new AnimatorListenerAdapter() { // from class: com.google.android.material.search.SearchViewAnimationHelper.5
|
||||
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
|
||||
public void onAnimationStart(Animator animator) {
|
||||
SearchViewAnimationHelper.this.setContentViewsAlpha(z ? 0.0f : 1.0f);
|
||||
}
|
||||
|
||||
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
|
||||
public void onAnimationEnd(Animator animator) {
|
||||
SearchViewAnimationHelper.this.setContentViewsAlpha(z ? 1.0f : 0.0f);
|
||||
SearchViewAnimationHelper.this.rootView.resetClipBoundsAndCornerRadius();
|
||||
}
|
||||
});
|
||||
return animatorSet;
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void setContentViewsAlpha(float f) {
|
||||
this.clearButton.setAlpha(f);
|
||||
this.divider.setAlpha(f);
|
||||
this.contentContainer.setAlpha(f);
|
||||
setActionMenuViewAlphaIfNeeded(f);
|
||||
}
|
||||
|
||||
private void setActionMenuViewAlphaIfNeeded(float f) {
|
||||
ActionMenuView actionMenuView;
|
||||
if (!this.searchView.isMenuItemsAnimated() || (actionMenuView = ToolbarUtils.getActionMenuView(this.toolbar)) == null) {
|
||||
return;
|
||||
}
|
||||
actionMenuView.setAlpha(f);
|
||||
}
|
||||
|
||||
private Animator getScrimAlphaAnimator(boolean z) {
|
||||
TimeInterpolator timeInterpolator = z ? AnimationUtils.LINEAR_INTERPOLATOR : AnimationUtils.FAST_OUT_SLOW_IN_INTERPOLATOR;
|
||||
ValueAnimator ofFloat = ValueAnimator.ofFloat(0.0f, 1.0f);
|
||||
ofFloat.setDuration(z ? 300L : 250L);
|
||||
ofFloat.setInterpolator(ReversableAnimatedValueInterpolator.of(z, timeInterpolator));
|
||||
ofFloat.addUpdateListener(MultiViewUpdateListener.alphaListener(this.scrim));
|
||||
return ofFloat;
|
||||
}
|
||||
|
||||
private Animator getRootViewAnimator(boolean z) {
|
||||
Rect initialHideToClipBounds = this.backHelper.getInitialHideToClipBounds();
|
||||
Rect initialHideFromClipBounds = this.backHelper.getInitialHideFromClipBounds();
|
||||
if (initialHideToClipBounds == null) {
|
||||
initialHideToClipBounds = ViewUtils.calculateRectFromBounds(this.searchView);
|
||||
}
|
||||
if (initialHideFromClipBounds == null) {
|
||||
initialHideFromClipBounds = ViewUtils.calculateOffsetRectFromBounds(this.rootView, this.searchBar);
|
||||
}
|
||||
final Rect rect = new Rect(initialHideFromClipBounds);
|
||||
final float cornerSize = this.searchBar.getCornerSize();
|
||||
final float max = Math.max(this.rootView.getCornerRadius(), this.backHelper.getExpandedCornerSize());
|
||||
ValueAnimator ofObject = ValueAnimator.ofObject(new RectEvaluator(rect), initialHideFromClipBounds, initialHideToClipBounds);
|
||||
ofObject.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { // from class: com.google.android.material.search.SearchViewAnimationHelper$$ExternalSyntheticLambda8
|
||||
@Override // android.animation.ValueAnimator.AnimatorUpdateListener
|
||||
public final void onAnimationUpdate(ValueAnimator valueAnimator) {
|
||||
SearchViewAnimationHelper.this.m257xa183b80f(cornerSize, max, rect, valueAnimator);
|
||||
}
|
||||
});
|
||||
ofObject.setDuration(z ? 300L : 250L);
|
||||
ofObject.setInterpolator(ReversableAnimatedValueInterpolator.of(z, AnimationUtils.FAST_OUT_SLOW_IN_INTERPOLATOR));
|
||||
return ofObject;
|
||||
}
|
||||
|
||||
/* renamed from: lambda$getRootViewAnimator$2$com-google-android-material-search-SearchViewAnimationHelper, reason: not valid java name */
|
||||
/* synthetic */ void m257xa183b80f(float f, float f2, Rect rect, ValueAnimator valueAnimator) {
|
||||
this.rootView.updateClipBoundsAndCornerRadius(rect, AnimationUtils.lerp(f, f2, valueAnimator.getAnimatedFraction()));
|
||||
}
|
||||
|
||||
private Animator getClearButtonAnimator(boolean z) {
|
||||
ValueAnimator ofFloat = ValueAnimator.ofFloat(0.0f, 1.0f);
|
||||
ofFloat.setDuration(z ? SHOW_CLEAR_BUTTON_ALPHA_DURATION_MS : HIDE_CLEAR_BUTTON_ALPHA_DURATION_MS);
|
||||
ofFloat.setStartDelay(z ? 250L : 0L);
|
||||
ofFloat.setInterpolator(ReversableAnimatedValueInterpolator.of(z, AnimationUtils.LINEAR_INTERPOLATOR));
|
||||
ofFloat.addUpdateListener(MultiViewUpdateListener.alphaListener(this.clearButton));
|
||||
return ofFloat;
|
||||
}
|
||||
|
||||
private AnimatorSet getButtonsProgressAnimator(boolean z) {
|
||||
AnimatorSet animatorSet = new AnimatorSet();
|
||||
addBackButtonProgressAnimatorIfNeeded(animatorSet);
|
||||
animatorSet.setDuration(z ? 300L : 250L);
|
||||
animatorSet.setInterpolator(ReversableAnimatedValueInterpolator.of(z, AnimationUtils.FAST_OUT_SLOW_IN_INTERPOLATOR));
|
||||
return animatorSet;
|
||||
}
|
||||
|
||||
private AnimatorSet getButtonsTranslationAnimator(boolean z) {
|
||||
AnimatorSet animatorSet = new AnimatorSet();
|
||||
addBackButtonTranslationAnimatorIfNeeded(animatorSet);
|
||||
addActionMenuViewAnimatorIfNeeded(animatorSet);
|
||||
animatorSet.setDuration(z ? 300L : 250L);
|
||||
animatorSet.setInterpolator(ReversableAnimatedValueInterpolator.of(z, AnimationUtils.FAST_OUT_SLOW_IN_INTERPOLATOR));
|
||||
return animatorSet;
|
||||
}
|
||||
|
||||
private void addBackButtonTranslationAnimatorIfNeeded(AnimatorSet animatorSet) {
|
||||
ImageButton navigationIconButton = ToolbarUtils.getNavigationIconButton(this.toolbar);
|
||||
if (navigationIconButton == null) {
|
||||
return;
|
||||
}
|
||||
ValueAnimator ofFloat = ValueAnimator.ofFloat(getFromTranslationXStart(navigationIconButton), 0.0f);
|
||||
ofFloat.addUpdateListener(MultiViewUpdateListener.translationXListener(navigationIconButton));
|
||||
ValueAnimator ofFloat2 = ValueAnimator.ofFloat(getFromTranslationY(), 0.0f);
|
||||
ofFloat2.addUpdateListener(MultiViewUpdateListener.translationYListener(navigationIconButton));
|
||||
animatorSet.playTogether(ofFloat, ofFloat2);
|
||||
}
|
||||
|
||||
private void addBackButtonProgressAnimatorIfNeeded(AnimatorSet animatorSet) {
|
||||
ImageButton navigationIconButton = ToolbarUtils.getNavigationIconButton(this.toolbar);
|
||||
if (navigationIconButton == null) {
|
||||
return;
|
||||
}
|
||||
Drawable unwrap = DrawableCompat.unwrap(navigationIconButton.getDrawable());
|
||||
if (this.searchView.isAnimatedNavigationIcon()) {
|
||||
addDrawerArrowDrawableAnimatorIfNeeded(animatorSet, unwrap);
|
||||
addFadeThroughDrawableAnimatorIfNeeded(animatorSet, unwrap);
|
||||
} else {
|
||||
setFullDrawableProgressIfNeeded(unwrap);
|
||||
}
|
||||
}
|
||||
|
||||
private void addDrawerArrowDrawableAnimatorIfNeeded(AnimatorSet animatorSet, Drawable drawable) {
|
||||
if (drawable instanceof DrawerArrowDrawable) {
|
||||
final DrawerArrowDrawable drawerArrowDrawable = (DrawerArrowDrawable) drawable;
|
||||
ValueAnimator ofFloat = ValueAnimator.ofFloat(0.0f, 1.0f);
|
||||
ofFloat.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { // from class: com.google.android.material.search.SearchViewAnimationHelper$$ExternalSyntheticLambda4
|
||||
@Override // android.animation.ValueAnimator.AnimatorUpdateListener
|
||||
public final void onAnimationUpdate(ValueAnimator valueAnimator) {
|
||||
DrawerArrowDrawable.this.setProgress(((Float) valueAnimator.getAnimatedValue()).floatValue());
|
||||
}
|
||||
});
|
||||
animatorSet.playTogether(ofFloat);
|
||||
}
|
||||
}
|
||||
|
||||
private void addFadeThroughDrawableAnimatorIfNeeded(AnimatorSet animatorSet, Drawable drawable) {
|
||||
if (drawable instanceof FadeThroughDrawable) {
|
||||
final FadeThroughDrawable fadeThroughDrawable = (FadeThroughDrawable) drawable;
|
||||
ValueAnimator ofFloat = ValueAnimator.ofFloat(0.0f, 1.0f);
|
||||
ofFloat.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { // from class: com.google.android.material.search.SearchViewAnimationHelper$$ExternalSyntheticLambda3
|
||||
@Override // android.animation.ValueAnimator.AnimatorUpdateListener
|
||||
public final void onAnimationUpdate(ValueAnimator valueAnimator) {
|
||||
FadeThroughDrawable.this.setProgress(((Float) valueAnimator.getAnimatedValue()).floatValue());
|
||||
}
|
||||
});
|
||||
animatorSet.playTogether(ofFloat);
|
||||
}
|
||||
}
|
||||
|
||||
private void setFullDrawableProgressIfNeeded(Drawable drawable) {
|
||||
if (drawable instanceof DrawerArrowDrawable) {
|
||||
((DrawerArrowDrawable) drawable).setProgress(1.0f);
|
||||
}
|
||||
if (drawable instanceof FadeThroughDrawable) {
|
||||
((FadeThroughDrawable) drawable).setProgress(1.0f);
|
||||
}
|
||||
}
|
||||
|
||||
private void addActionMenuViewAnimatorIfNeeded(AnimatorSet animatorSet) {
|
||||
ActionMenuView actionMenuView = ToolbarUtils.getActionMenuView(this.toolbar);
|
||||
if (actionMenuView == null) {
|
||||
return;
|
||||
}
|
||||
ValueAnimator ofFloat = ValueAnimator.ofFloat(getFromTranslationXEnd(actionMenuView), 0.0f);
|
||||
ofFloat.addUpdateListener(MultiViewUpdateListener.translationXListener(actionMenuView));
|
||||
ValueAnimator ofFloat2 = ValueAnimator.ofFloat(getFromTranslationY(), 0.0f);
|
||||
ofFloat2.addUpdateListener(MultiViewUpdateListener.translationYListener(actionMenuView));
|
||||
animatorSet.playTogether(ofFloat, ofFloat2);
|
||||
}
|
||||
|
||||
private Animator getDummyToolbarAnimator(boolean z) {
|
||||
return getTranslationAnimator(z, false, this.dummyToolbar);
|
||||
}
|
||||
|
||||
private Animator getHeaderContainerAnimator(boolean z) {
|
||||
return getTranslationAnimator(z, false, this.headerContainer);
|
||||
}
|
||||
|
||||
private Animator getActionMenuViewsAlphaAnimator(boolean z) {
|
||||
ValueAnimator ofFloat = ValueAnimator.ofFloat(0.0f, 1.0f);
|
||||
ofFloat.setDuration(z ? 300L : 250L);
|
||||
ofFloat.setInterpolator(ReversableAnimatedValueInterpolator.of(z, AnimationUtils.FAST_OUT_SLOW_IN_INTERPOLATOR));
|
||||
if (this.searchView.isMenuItemsAnimated()) {
|
||||
ofFloat.addUpdateListener(new FadeThroughUpdateListener(ToolbarUtils.getActionMenuView(this.dummyToolbar), ToolbarUtils.getActionMenuView(this.toolbar)));
|
||||
}
|
||||
return ofFloat;
|
||||
}
|
||||
|
||||
private Animator getSearchPrefixAnimator(boolean z) {
|
||||
return getTranslationAnimator(z, true, this.searchPrefix);
|
||||
}
|
||||
|
||||
private Animator getEditTextAnimator(boolean z) {
|
||||
return getTranslationAnimator(z, true, this.editText);
|
||||
}
|
||||
|
||||
private Animator getContentAnimator(boolean z) {
|
||||
AnimatorSet animatorSet = new AnimatorSet();
|
||||
animatorSet.playTogether(getContentAlphaAnimator(z), getDividerAnimator(z), getContentScaleAnimator(z));
|
||||
return animatorSet;
|
||||
}
|
||||
|
||||
private Animator getContentAlphaAnimator(boolean z) {
|
||||
ValueAnimator ofFloat = ValueAnimator.ofFloat(0.0f, 1.0f);
|
||||
ofFloat.setDuration(z ? 150L : HIDE_CONTENT_ALPHA_DURATION_MS);
|
||||
ofFloat.setStartDelay(z ? 75L : 0L);
|
||||
ofFloat.setInterpolator(ReversableAnimatedValueInterpolator.of(z, AnimationUtils.LINEAR_INTERPOLATOR));
|
||||
ofFloat.addUpdateListener(MultiViewUpdateListener.alphaListener(this.divider, this.contentContainer));
|
||||
return ofFloat;
|
||||
}
|
||||
|
||||
private Animator getDividerAnimator(boolean z) {
|
||||
ValueAnimator ofFloat = ValueAnimator.ofFloat((this.contentContainer.getHeight() * 0.050000012f) / 2.0f, 0.0f);
|
||||
ofFloat.setDuration(z ? 300L : 250L);
|
||||
ofFloat.setInterpolator(ReversableAnimatedValueInterpolator.of(z, AnimationUtils.FAST_OUT_SLOW_IN_INTERPOLATOR));
|
||||
ofFloat.addUpdateListener(MultiViewUpdateListener.translationYListener(this.divider));
|
||||
return ofFloat;
|
||||
}
|
||||
|
||||
private Animator getContentScaleAnimator(boolean z) {
|
||||
ValueAnimator ofFloat = ValueAnimator.ofFloat(CONTENT_FROM_SCALE, 1.0f);
|
||||
ofFloat.setDuration(z ? 300L : 250L);
|
||||
ofFloat.setInterpolator(ReversableAnimatedValueInterpolator.of(z, AnimationUtils.FAST_OUT_SLOW_IN_INTERPOLATOR));
|
||||
ofFloat.addUpdateListener(MultiViewUpdateListener.scaleListener(this.contentContainer));
|
||||
return ofFloat;
|
||||
}
|
||||
|
||||
private Animator getTranslationAnimator(boolean z, boolean z2, View view) {
|
||||
ValueAnimator ofFloat = ValueAnimator.ofFloat(z2 ? getFromTranslationXStart(view) : getFromTranslationXEnd(view), 0.0f);
|
||||
ofFloat.addUpdateListener(MultiViewUpdateListener.translationXListener(view));
|
||||
ValueAnimator ofFloat2 = ValueAnimator.ofFloat(getFromTranslationY(), 0.0f);
|
||||
ofFloat2.addUpdateListener(MultiViewUpdateListener.translationYListener(view));
|
||||
AnimatorSet animatorSet = new AnimatorSet();
|
||||
animatorSet.playTogether(ofFloat, ofFloat2);
|
||||
animatorSet.setDuration(z ? 300L : 250L);
|
||||
animatorSet.setInterpolator(ReversableAnimatedValueInterpolator.of(z, AnimationUtils.FAST_OUT_SLOW_IN_INTERPOLATOR));
|
||||
return animatorSet;
|
||||
}
|
||||
|
||||
private int getFromTranslationXStart(View view) {
|
||||
int marginStart = MarginLayoutParamsCompat.getMarginStart((ViewGroup.MarginLayoutParams) view.getLayoutParams());
|
||||
int paddingStart = ViewCompat.getPaddingStart(this.searchBar);
|
||||
if (ViewUtils.isLayoutRtl(this.searchBar)) {
|
||||
return ((this.searchBar.getWidth() - this.searchBar.getRight()) + marginStart) - paddingStart;
|
||||
}
|
||||
return (this.searchBar.getLeft() - marginStart) + paddingStart;
|
||||
}
|
||||
|
||||
private int getFromTranslationXEnd(View view) {
|
||||
int marginEnd = MarginLayoutParamsCompat.getMarginEnd((ViewGroup.MarginLayoutParams) view.getLayoutParams());
|
||||
if (ViewUtils.isLayoutRtl(this.searchBar)) {
|
||||
return this.searchBar.getLeft() - marginEnd;
|
||||
}
|
||||
return (this.searchBar.getRight() - this.searchView.getWidth()) + marginEnd;
|
||||
}
|
||||
|
||||
private int getFromTranslationY() {
|
||||
return ((this.searchBar.getTop() + this.searchBar.getBottom()) / 2) - ((this.toolbarContainer.getTop() + this.toolbarContainer.getBottom()) / 2);
|
||||
}
|
||||
|
||||
private void setUpDummyToolbarIfNeeded() {
|
||||
Menu menu = this.dummyToolbar.getMenu();
|
||||
if (menu != null) {
|
||||
menu.clear();
|
||||
}
|
||||
if (this.searchBar.getMenuResId() != -1 && this.searchView.isMenuItemsAnimated()) {
|
||||
this.dummyToolbar.inflateMenu(this.searchBar.getMenuResId());
|
||||
setMenuItemsNotClickable(this.dummyToolbar);
|
||||
this.dummyToolbar.setVisibility(0);
|
||||
return;
|
||||
}
|
||||
this.dummyToolbar.setVisibility(8);
|
||||
}
|
||||
|
||||
private void setMenuItemsNotClickable(Toolbar toolbar) {
|
||||
ActionMenuView actionMenuView = ToolbarUtils.getActionMenuView(toolbar);
|
||||
if (actionMenuView != null) {
|
||||
for (int i = 0; i < actionMenuView.getChildCount(); i++) {
|
||||
View childAt = actionMenuView.getChildAt(i);
|
||||
childAt.setClickable(false);
|
||||
childAt.setFocusable(false);
|
||||
childAt.setFocusableInTouchMode(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void startBackProgress(BackEventCompat backEventCompat) {
|
||||
this.backHelper.startBackProgress(backEventCompat, this.searchBar);
|
||||
}
|
||||
|
||||
public void updateBackProgress(BackEventCompat backEventCompat) {
|
||||
if (backEventCompat.getProgress() <= 0.0f) {
|
||||
return;
|
||||
}
|
||||
MaterialMainContainerBackHelper materialMainContainerBackHelper = this.backHelper;
|
||||
SearchBar searchBar = this.searchBar;
|
||||
materialMainContainerBackHelper.updateBackProgress(backEventCompat, searchBar, searchBar.getCornerSize());
|
||||
AnimatorSet animatorSet = this.backProgressAnimatorSet;
|
||||
if (animatorSet == null) {
|
||||
if (this.searchView.isAdjustNothingSoftInputMode()) {
|
||||
this.searchView.clearFocusAndHideKeyboard();
|
||||
}
|
||||
if (this.searchView.isAnimatedNavigationIcon()) {
|
||||
AnimatorSet buttonsProgressAnimator = getButtonsProgressAnimator(false);
|
||||
this.backProgressAnimatorSet = buttonsProgressAnimator;
|
||||
buttonsProgressAnimator.start();
|
||||
this.backProgressAnimatorSet.pause();
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
animatorSet.setCurrentPlayTime((long) (backEventCompat.getProgress() * this.backProgressAnimatorSet.getDuration()));
|
||||
}
|
||||
|
||||
public BackEventCompat onHandleBackInvoked() {
|
||||
return this.backHelper.onHandleBackInvoked();
|
||||
}
|
||||
|
||||
public void finishBackProgress() {
|
||||
long totalDuration;
|
||||
totalDuration = hide().getTotalDuration();
|
||||
this.backHelper.finishBackProgress(totalDuration, this.searchBar);
|
||||
if (this.backProgressAnimatorSet != null) {
|
||||
getButtonsTranslationAnimator(false).start();
|
||||
this.backProgressAnimatorSet.resume();
|
||||
}
|
||||
this.backProgressAnimatorSet = null;
|
||||
}
|
||||
|
||||
public void cancelBackProgress() {
|
||||
this.backHelper.cancelBackProgress(this.searchBar);
|
||||
AnimatorSet animatorSet = this.backProgressAnimatorSet;
|
||||
if (animatorSet != null) {
|
||||
animatorSet.reverse();
|
||||
}
|
||||
this.backProgressAnimatorSet = null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user