mirror of
https://github.com/VibedByKaKi/alexandroid.git
synced 2026-11-18 11:57:18 +01:00
165 lines
6.9 KiB
Java
165 lines
6.9 KiB
Java
package com.google.android.material.internal;
|
|
|
|
import android.animation.Animator;
|
|
import android.animation.AnimatorListenerAdapter;
|
|
import android.animation.AnimatorSet;
|
|
import android.animation.ValueAnimator;
|
|
import android.graphics.Rect;
|
|
import android.view.View;
|
|
import androidx.annotation.NonNull;
|
|
import androidx.annotation.Nullable;
|
|
import androidx.annotation.RestrictTo;
|
|
import com.google.android.material.animation.AnimationUtils;
|
|
import com.google.android.material.appbar.AppBarLayout$$ExternalSyntheticLambda1;
|
|
import com.google.errorprone.annotations.CanIgnoreReturnValue;
|
|
import java.util.ArrayList;
|
|
import java.util.Collection;
|
|
import java.util.Collections;
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
|
|
/* loaded from: classes7.dex */
|
|
public class ExpandCollapseAnimationHelper {
|
|
|
|
@Nullable
|
|
private ValueAnimator.AnimatorUpdateListener additionalUpdateListener;
|
|
private final View collapsedView;
|
|
private int collapsedViewOffsetY;
|
|
private long duration;
|
|
private final View expandedView;
|
|
private int expandedViewOffsetY;
|
|
private final List<AnimatorListenerAdapter> listeners = new ArrayList();
|
|
private final List<View> endAnchoredViews = new ArrayList();
|
|
|
|
public ExpandCollapseAnimationHelper(@NonNull View view, @NonNull View view2) {
|
|
this.collapsedView = view;
|
|
this.expandedView = view2;
|
|
}
|
|
|
|
private void addListeners(Animator animator, List<AnimatorListenerAdapter> list) {
|
|
Iterator<AnimatorListenerAdapter> it2 = list.iterator();
|
|
while (it2.hasNext()) {
|
|
animator.addListener(it2.next());
|
|
}
|
|
}
|
|
|
|
private AnimatorSet getAnimatorSet(boolean z) {
|
|
AnimatorSet animatorSet = new AnimatorSet();
|
|
animatorSet.playTogether(getExpandCollapseAnimator(z), getExpandedViewChildrenAlphaAnimator(z), getEndAnchoredViewsTranslateAnimator(z));
|
|
return animatorSet;
|
|
}
|
|
|
|
private Animator getEndAnchoredViewsTranslateAnimator(boolean z) {
|
|
ValueAnimator ofFloat = ValueAnimator.ofFloat((this.collapsedView.getRight() - this.expandedView.getRight()) + (this.expandedView.getLeft() - this.collapsedView.getLeft()), 0.0f);
|
|
ofFloat.addUpdateListener(MultiViewUpdateListener.translationXListener(this.endAnchoredViews));
|
|
ofFloat.setDuration(this.duration);
|
|
ofFloat.setInterpolator(ReversableAnimatedValueInterpolator.of(z, AnimationUtils.FAST_OUT_SLOW_IN_INTERPOLATOR));
|
|
return ofFloat;
|
|
}
|
|
|
|
private Animator getExpandCollapseAnimator(boolean z) {
|
|
Rect calculateRectFromBounds = ViewUtils.calculateRectFromBounds(this.collapsedView, this.collapsedViewOffsetY);
|
|
Rect calculateRectFromBounds2 = ViewUtils.calculateRectFromBounds(this.expandedView, this.expandedViewOffsetY);
|
|
Rect rect = new Rect(calculateRectFromBounds);
|
|
ValueAnimator ofObject = ValueAnimator.ofObject(new RectEvaluator(rect), calculateRectFromBounds, calculateRectFromBounds2);
|
|
ofObject.addUpdateListener(new AppBarLayout$$ExternalSyntheticLambda1(this, rect, 1));
|
|
ValueAnimator.AnimatorUpdateListener animatorUpdateListener = this.additionalUpdateListener;
|
|
if (animatorUpdateListener != null) {
|
|
ofObject.addUpdateListener(animatorUpdateListener);
|
|
}
|
|
ofObject.setDuration(this.duration);
|
|
ofObject.setInterpolator(ReversableAnimatedValueInterpolator.of(z, AnimationUtils.FAST_OUT_SLOW_IN_INTERPOLATOR));
|
|
return ofObject;
|
|
}
|
|
|
|
private Animator getExpandedViewChildrenAlphaAnimator(boolean z) {
|
|
List<View> children = ViewUtils.getChildren(this.expandedView);
|
|
ValueAnimator ofFloat = ValueAnimator.ofFloat(0.0f, 1.0f);
|
|
ofFloat.addUpdateListener(MultiViewUpdateListener.alphaListener(children));
|
|
ofFloat.setDuration(this.duration);
|
|
ofFloat.setInterpolator(ReversableAnimatedValueInterpolator.of(z, AnimationUtils.LINEAR_INTERPOLATOR));
|
|
return ofFloat;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public /* synthetic */ void lambda$getExpandCollapseAnimator$0(Rect rect, ValueAnimator valueAnimator) {
|
|
ViewUtils.setBoundsFromRect(this.expandedView, rect);
|
|
}
|
|
|
|
@NonNull
|
|
@CanIgnoreReturnValue
|
|
public ExpandCollapseAnimationHelper addEndAnchoredViews(@NonNull View... viewArr) {
|
|
Collections.addAll(this.endAnchoredViews, viewArr);
|
|
return this;
|
|
}
|
|
|
|
@NonNull
|
|
@CanIgnoreReturnValue
|
|
public ExpandCollapseAnimationHelper addListener(@NonNull AnimatorListenerAdapter animatorListenerAdapter) {
|
|
this.listeners.add(animatorListenerAdapter);
|
|
return this;
|
|
}
|
|
|
|
@NonNull
|
|
public Animator getCollapseAnimator() {
|
|
AnimatorSet animatorSet = getAnimatorSet(false);
|
|
animatorSet.addListener(new AnimatorListenerAdapter() { // from class: com.google.android.material.internal.ExpandCollapseAnimationHelper.2
|
|
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
|
|
public void onAnimationEnd(Animator animator) {
|
|
ExpandCollapseAnimationHelper.this.expandedView.setVisibility(8);
|
|
}
|
|
});
|
|
addListeners(animatorSet, this.listeners);
|
|
return animatorSet;
|
|
}
|
|
|
|
@NonNull
|
|
public Animator getExpandAnimator() {
|
|
AnimatorSet animatorSet = getAnimatorSet(true);
|
|
animatorSet.addListener(new AnimatorListenerAdapter() { // from class: com.google.android.material.internal.ExpandCollapseAnimationHelper.1
|
|
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
|
|
public void onAnimationStart(Animator animator) {
|
|
ExpandCollapseAnimationHelper.this.expandedView.setVisibility(0);
|
|
}
|
|
});
|
|
addListeners(animatorSet, this.listeners);
|
|
return animatorSet;
|
|
}
|
|
|
|
@NonNull
|
|
@CanIgnoreReturnValue
|
|
public ExpandCollapseAnimationHelper setAdditionalUpdateListener(@Nullable ValueAnimator.AnimatorUpdateListener animatorUpdateListener) {
|
|
this.additionalUpdateListener = animatorUpdateListener;
|
|
return this;
|
|
}
|
|
|
|
@NonNull
|
|
@CanIgnoreReturnValue
|
|
public ExpandCollapseAnimationHelper setCollapsedViewOffsetY(int i) {
|
|
this.collapsedViewOffsetY = i;
|
|
return this;
|
|
}
|
|
|
|
@NonNull
|
|
@CanIgnoreReturnValue
|
|
public ExpandCollapseAnimationHelper setDuration(long j) {
|
|
this.duration = j;
|
|
return this;
|
|
}
|
|
|
|
@NonNull
|
|
@CanIgnoreReturnValue
|
|
public ExpandCollapseAnimationHelper setExpandedViewOffsetY(int i) {
|
|
this.expandedViewOffsetY = i;
|
|
return this;
|
|
}
|
|
|
|
@NonNull
|
|
@CanIgnoreReturnValue
|
|
public ExpandCollapseAnimationHelper addEndAnchoredViews(@NonNull Collection<View> collection) {
|
|
this.endAnchoredViews.addAll(collection);
|
|
return this;
|
|
}
|
|
}
|