ADD week 5
This commit is contained in:
@ -0,0 +1,102 @@
|
||||
package com.google.android.material.transformation;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewTreeObserver;
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import com.google.android.material.expandable.ExpandableWidget;
|
||||
import java.util.List;
|
||||
|
||||
@Deprecated
|
||||
/* loaded from: classes.dex */
|
||||
public abstract class ExpandableBehavior extends CoordinatorLayout.Behavior<View> {
|
||||
private static final int STATE_COLLAPSED = 2;
|
||||
private static final int STATE_EXPANDED = 1;
|
||||
private static final int STATE_UNINITIALIZED = 0;
|
||||
private int currentState;
|
||||
|
||||
private boolean didStateChange(boolean z) {
|
||||
if (!z) {
|
||||
return this.currentState == 1;
|
||||
}
|
||||
int i = this.currentState;
|
||||
return i == 0 || i == 2;
|
||||
}
|
||||
|
||||
@Override // androidx.coordinatorlayout.widget.CoordinatorLayout.Behavior
|
||||
public abstract boolean layoutDependsOn(CoordinatorLayout coordinatorLayout, View view, View view2);
|
||||
|
||||
protected abstract boolean onExpandedStateChange(View view, View view2, boolean z, boolean z2);
|
||||
|
||||
public ExpandableBehavior() {
|
||||
this.currentState = 0;
|
||||
}
|
||||
|
||||
public ExpandableBehavior(Context context, AttributeSet attributeSet) {
|
||||
super(context, attributeSet);
|
||||
this.currentState = 0;
|
||||
}
|
||||
|
||||
@Override // androidx.coordinatorlayout.widget.CoordinatorLayout.Behavior
|
||||
public boolean onLayoutChild(CoordinatorLayout coordinatorLayout, final View view, int i) {
|
||||
final ExpandableWidget findExpandableWidget;
|
||||
if (ViewCompat.isLaidOut(view) || (findExpandableWidget = findExpandableWidget(coordinatorLayout, view)) == null || !didStateChange(findExpandableWidget.isExpanded())) {
|
||||
return false;
|
||||
}
|
||||
final int i2 = findExpandableWidget.isExpanded() ? 1 : 2;
|
||||
this.currentState = i2;
|
||||
view.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { // from class: com.google.android.material.transformation.ExpandableBehavior.1
|
||||
/* JADX WARN: Multi-variable type inference failed */
|
||||
@Override // android.view.ViewTreeObserver.OnPreDrawListener
|
||||
public boolean onPreDraw() {
|
||||
view.getViewTreeObserver().removeOnPreDrawListener(this);
|
||||
if (ExpandableBehavior.this.currentState == i2) {
|
||||
ExpandableBehavior expandableBehavior = ExpandableBehavior.this;
|
||||
ExpandableWidget expandableWidget = findExpandableWidget;
|
||||
expandableBehavior.onExpandedStateChange((View) expandableWidget, view, expandableWidget.isExpanded(), false);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
/* JADX WARN: Multi-variable type inference failed */
|
||||
@Override // androidx.coordinatorlayout.widget.CoordinatorLayout.Behavior
|
||||
public boolean onDependentViewChanged(CoordinatorLayout coordinatorLayout, View view, View view2) {
|
||||
ExpandableWidget expandableWidget = (ExpandableWidget) view2;
|
||||
if (!didStateChange(expandableWidget.isExpanded())) {
|
||||
return false;
|
||||
}
|
||||
this.currentState = expandableWidget.isExpanded() ? 1 : 2;
|
||||
return onExpandedStateChange((View) expandableWidget, view, expandableWidget.isExpanded(), true);
|
||||
}
|
||||
|
||||
/* JADX WARN: Multi-variable type inference failed */
|
||||
protected ExpandableWidget findExpandableWidget(CoordinatorLayout coordinatorLayout, View view) {
|
||||
List<View> dependencies = coordinatorLayout.getDependencies(view);
|
||||
int size = dependencies.size();
|
||||
for (int i = 0; i < size; i++) {
|
||||
View view2 = dependencies.get(i);
|
||||
if (layoutDependsOn(coordinatorLayout, view, view2)) {
|
||||
return (ExpandableWidget) view2;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static <T extends ExpandableBehavior> T from(View view, Class<T> cls) {
|
||||
ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
|
||||
if (!(layoutParams instanceof CoordinatorLayout.LayoutParams)) {
|
||||
throw new IllegalArgumentException("The view is not a child of CoordinatorLayout");
|
||||
}
|
||||
CoordinatorLayout.Behavior behavior = ((CoordinatorLayout.LayoutParams) layoutParams).getBehavior();
|
||||
if (!(behavior instanceof ExpandableBehavior)) {
|
||||
throw new IllegalArgumentException("The view is not associated with ExpandableBehavior");
|
||||
}
|
||||
return cls.cast(behavior);
|
||||
}
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
package com.google.android.material.transformation;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.animation.AnimatorSet;
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
|
||||
@Deprecated
|
||||
/* loaded from: classes.dex */
|
||||
public abstract class ExpandableTransformationBehavior extends ExpandableBehavior {
|
||||
private AnimatorSet currentAnimation;
|
||||
|
||||
protected abstract AnimatorSet onCreateExpandedStateChangeAnimation(View view, View view2, boolean z, boolean z2);
|
||||
|
||||
public ExpandableTransformationBehavior() {
|
||||
}
|
||||
|
||||
public ExpandableTransformationBehavior(Context context, AttributeSet attributeSet) {
|
||||
super(context, attributeSet);
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.transformation.ExpandableBehavior
|
||||
protected boolean onExpandedStateChange(View view, View view2, boolean z, boolean z2) {
|
||||
AnimatorSet animatorSet = this.currentAnimation;
|
||||
boolean z3 = animatorSet != null;
|
||||
if (z3) {
|
||||
animatorSet.cancel();
|
||||
}
|
||||
AnimatorSet onCreateExpandedStateChangeAnimation = onCreateExpandedStateChangeAnimation(view, view2, z, z3);
|
||||
this.currentAnimation = onCreateExpandedStateChangeAnimation;
|
||||
onCreateExpandedStateChangeAnimation.addListener(new AnimatorListenerAdapter() { // from class: com.google.android.material.transformation.ExpandableTransformationBehavior.1
|
||||
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
|
||||
public void onAnimationEnd(Animator animator) {
|
||||
ExpandableTransformationBehavior.this.currentAnimation = null;
|
||||
}
|
||||
});
|
||||
this.currentAnimation.start();
|
||||
if (!z2) {
|
||||
this.currentAnimation.end();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,495 @@
|
||||
package com.google.android.material.transformation;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.animation.AnimatorSet;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.content.Context;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Pair;
|
||||
import android.util.Property;
|
||||
import android.view.View;
|
||||
import android.view.ViewAnimationUtils;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import androidx.constraintlayout.core.motion.utils.TypedValues;
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import com.google.android.material.R;
|
||||
import com.google.android.material.animation.AnimationUtils;
|
||||
import com.google.android.material.animation.AnimatorSetCompat;
|
||||
import com.google.android.material.animation.ArgbEvaluatorCompat;
|
||||
import com.google.android.material.animation.ChildrenAlphaProperty;
|
||||
import com.google.android.material.animation.DrawableAlphaProperty;
|
||||
import com.google.android.material.animation.MotionSpec;
|
||||
import com.google.android.material.animation.MotionTiming;
|
||||
import com.google.android.material.animation.Positioning;
|
||||
import com.google.android.material.circularreveal.CircularRevealCompat;
|
||||
import com.google.android.material.circularreveal.CircularRevealHelper;
|
||||
import com.google.android.material.circularreveal.CircularRevealWidget;
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
import com.google.android.material.math.MathUtils;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Deprecated
|
||||
/* loaded from: classes.dex */
|
||||
public abstract class FabTransformationBehavior extends ExpandableTransformationBehavior {
|
||||
private float dependencyOriginalTranslationX;
|
||||
private float dependencyOriginalTranslationY;
|
||||
private final int[] tmpArray;
|
||||
private final Rect tmpRect;
|
||||
private final RectF tmpRectF1;
|
||||
private final RectF tmpRectF2;
|
||||
|
||||
protected abstract FabTransformationSpec onCreateMotionSpec(Context context, boolean z);
|
||||
|
||||
public FabTransformationBehavior() {
|
||||
this.tmpRect = new Rect();
|
||||
this.tmpRectF1 = new RectF();
|
||||
this.tmpRectF2 = new RectF();
|
||||
this.tmpArray = new int[2];
|
||||
}
|
||||
|
||||
public FabTransformationBehavior(Context context, AttributeSet attributeSet) {
|
||||
super(context, attributeSet);
|
||||
this.tmpRect = new Rect();
|
||||
this.tmpRectF1 = new RectF();
|
||||
this.tmpRectF2 = new RectF();
|
||||
this.tmpArray = new int[2];
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.transformation.ExpandableBehavior, androidx.coordinatorlayout.widget.CoordinatorLayout.Behavior
|
||||
public boolean layoutDependsOn(CoordinatorLayout coordinatorLayout, View view, View view2) {
|
||||
if (view.getVisibility() == 8) {
|
||||
throw new IllegalStateException("This behavior cannot be attached to a GONE view. Set the view to INVISIBLE instead.");
|
||||
}
|
||||
if (!(view2 instanceof FloatingActionButton)) {
|
||||
return false;
|
||||
}
|
||||
int expandedComponentIdHint = ((FloatingActionButton) view2).getExpandedComponentIdHint();
|
||||
return expandedComponentIdHint == 0 || expandedComponentIdHint == view.getId();
|
||||
}
|
||||
|
||||
@Override // androidx.coordinatorlayout.widget.CoordinatorLayout.Behavior
|
||||
public void onAttachedToLayoutParams(CoordinatorLayout.LayoutParams layoutParams) {
|
||||
if (layoutParams.dodgeInsetEdges == 0) {
|
||||
layoutParams.dodgeInsetEdges = 80;
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.transformation.ExpandableTransformationBehavior
|
||||
protected AnimatorSet onCreateExpandedStateChangeAnimation(final View view, final View view2, final boolean z, boolean z2) {
|
||||
FabTransformationSpec onCreateMotionSpec = onCreateMotionSpec(view2.getContext(), z);
|
||||
if (z) {
|
||||
this.dependencyOriginalTranslationX = view.getTranslationX();
|
||||
this.dependencyOriginalTranslationY = view.getTranslationY();
|
||||
}
|
||||
ArrayList arrayList = new ArrayList();
|
||||
ArrayList arrayList2 = new ArrayList();
|
||||
createElevationAnimation(view, view2, z, z2, onCreateMotionSpec, arrayList, arrayList2);
|
||||
RectF rectF = this.tmpRectF1;
|
||||
createTranslationAnimation(view, view2, z, z2, onCreateMotionSpec, arrayList, arrayList2, rectF);
|
||||
float width = rectF.width();
|
||||
float height = rectF.height();
|
||||
createDependencyTranslationAnimation(view, view2, z, onCreateMotionSpec, arrayList);
|
||||
createIconFadeAnimation(view, view2, z, z2, onCreateMotionSpec, arrayList, arrayList2);
|
||||
createExpansionAnimation(view, view2, z, z2, onCreateMotionSpec, width, height, arrayList, arrayList2);
|
||||
createColorAnimation(view, view2, z, z2, onCreateMotionSpec, arrayList, arrayList2);
|
||||
createChildrenFadeAnimation(view, view2, z, z2, onCreateMotionSpec, arrayList, arrayList2);
|
||||
AnimatorSet animatorSet = new AnimatorSet();
|
||||
AnimatorSetCompat.playTogether(animatorSet, arrayList);
|
||||
animatorSet.addListener(new AnimatorListenerAdapter() { // from class: com.google.android.material.transformation.FabTransformationBehavior.1
|
||||
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
|
||||
public void onAnimationStart(Animator animator) {
|
||||
if (z) {
|
||||
view2.setVisibility(0);
|
||||
view.setAlpha(0.0f);
|
||||
view.setVisibility(4);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
|
||||
public void onAnimationEnd(Animator animator) {
|
||||
if (z) {
|
||||
return;
|
||||
}
|
||||
view2.setVisibility(4);
|
||||
view.setAlpha(1.0f);
|
||||
view.setVisibility(0);
|
||||
}
|
||||
});
|
||||
int size = arrayList2.size();
|
||||
for (int i = 0; i < size; i++) {
|
||||
animatorSet.addListener(arrayList2.get(i));
|
||||
}
|
||||
return animatorSet;
|
||||
}
|
||||
|
||||
private void createElevationAnimation(View view, View view2, boolean z, boolean z2, FabTransformationSpec fabTransformationSpec, List<Animator> list, List<Animator.AnimatorListener> list2) {
|
||||
ObjectAnimator ofFloat;
|
||||
float elevation = ViewCompat.getElevation(view2) - ViewCompat.getElevation(view);
|
||||
if (z) {
|
||||
if (!z2) {
|
||||
view2.setTranslationZ(-elevation);
|
||||
}
|
||||
ofFloat = ObjectAnimator.ofFloat(view2, (Property<View, Float>) View.TRANSLATION_Z, 0.0f);
|
||||
} else {
|
||||
ofFloat = ObjectAnimator.ofFloat(view2, (Property<View, Float>) View.TRANSLATION_Z, -elevation);
|
||||
}
|
||||
fabTransformationSpec.timings.getTiming("elevation").apply(ofFloat);
|
||||
list.add(ofFloat);
|
||||
}
|
||||
|
||||
private void createDependencyTranslationAnimation(View view, View view2, boolean z, FabTransformationSpec fabTransformationSpec, List<Animator> list) {
|
||||
float calculateTranslationX = calculateTranslationX(view, view2, fabTransformationSpec.positioning);
|
||||
float calculateTranslationY = calculateTranslationY(view, view2, fabTransformationSpec.positioning);
|
||||
Pair<MotionTiming, MotionTiming> calculateMotionTiming = calculateMotionTiming(calculateTranslationX, calculateTranslationY, z, fabTransformationSpec);
|
||||
MotionTiming motionTiming = (MotionTiming) calculateMotionTiming.first;
|
||||
MotionTiming motionTiming2 = (MotionTiming) calculateMotionTiming.second;
|
||||
Property property = View.TRANSLATION_X;
|
||||
float[] fArr = new float[1];
|
||||
if (!z) {
|
||||
calculateTranslationX = this.dependencyOriginalTranslationX;
|
||||
}
|
||||
fArr[0] = calculateTranslationX;
|
||||
ObjectAnimator ofFloat = ObjectAnimator.ofFloat(view, (Property<View, Float>) property, fArr);
|
||||
Property property2 = View.TRANSLATION_Y;
|
||||
float[] fArr2 = new float[1];
|
||||
if (!z) {
|
||||
calculateTranslationY = this.dependencyOriginalTranslationY;
|
||||
}
|
||||
fArr2[0] = calculateTranslationY;
|
||||
ObjectAnimator ofFloat2 = ObjectAnimator.ofFloat(view, (Property<View, Float>) property2, fArr2);
|
||||
motionTiming.apply(ofFloat);
|
||||
motionTiming2.apply(ofFloat2);
|
||||
list.add(ofFloat);
|
||||
list.add(ofFloat2);
|
||||
}
|
||||
|
||||
private void createTranslationAnimation(View view, View view2, boolean z, boolean z2, FabTransformationSpec fabTransformationSpec, List<Animator> list, List<Animator.AnimatorListener> list2, RectF rectF) {
|
||||
ObjectAnimator ofFloat;
|
||||
ObjectAnimator ofFloat2;
|
||||
float calculateTranslationX = calculateTranslationX(view, view2, fabTransformationSpec.positioning);
|
||||
float calculateTranslationY = calculateTranslationY(view, view2, fabTransformationSpec.positioning);
|
||||
Pair<MotionTiming, MotionTiming> calculateMotionTiming = calculateMotionTiming(calculateTranslationX, calculateTranslationY, z, fabTransformationSpec);
|
||||
MotionTiming motionTiming = (MotionTiming) calculateMotionTiming.first;
|
||||
MotionTiming motionTiming2 = (MotionTiming) calculateMotionTiming.second;
|
||||
if (z) {
|
||||
if (!z2) {
|
||||
view2.setTranslationX(-calculateTranslationX);
|
||||
view2.setTranslationY(-calculateTranslationY);
|
||||
}
|
||||
ofFloat = ObjectAnimator.ofFloat(view2, (Property<View, Float>) View.TRANSLATION_X, 0.0f);
|
||||
ofFloat2 = ObjectAnimator.ofFloat(view2, (Property<View, Float>) View.TRANSLATION_Y, 0.0f);
|
||||
calculateChildVisibleBoundsAtEndOfExpansion(view2, fabTransformationSpec, motionTiming, motionTiming2, -calculateTranslationX, -calculateTranslationY, 0.0f, 0.0f, rectF);
|
||||
} else {
|
||||
ofFloat = ObjectAnimator.ofFloat(view2, (Property<View, Float>) View.TRANSLATION_X, -calculateTranslationX);
|
||||
ofFloat2 = ObjectAnimator.ofFloat(view2, (Property<View, Float>) View.TRANSLATION_Y, -calculateTranslationY);
|
||||
}
|
||||
motionTiming.apply(ofFloat);
|
||||
motionTiming2.apply(ofFloat2);
|
||||
list.add(ofFloat);
|
||||
list.add(ofFloat2);
|
||||
}
|
||||
|
||||
/* JADX WARN: Multi-variable type inference failed */
|
||||
private void createIconFadeAnimation(View view, final View view2, boolean z, boolean z2, FabTransformationSpec fabTransformationSpec, List<Animator> list, List<Animator.AnimatorListener> list2) {
|
||||
ObjectAnimator ofInt;
|
||||
if ((view2 instanceof CircularRevealWidget) && (view instanceof ImageView)) {
|
||||
final CircularRevealWidget circularRevealWidget = (CircularRevealWidget) view2;
|
||||
final Drawable drawable = ((ImageView) view).getDrawable();
|
||||
if (drawable == null) {
|
||||
return;
|
||||
}
|
||||
drawable.mutate();
|
||||
if (z) {
|
||||
if (!z2) {
|
||||
drawable.setAlpha(255);
|
||||
}
|
||||
ofInt = ObjectAnimator.ofInt(drawable, DrawableAlphaProperty.DRAWABLE_ALPHA_COMPAT, 0);
|
||||
} else {
|
||||
ofInt = ObjectAnimator.ofInt(drawable, DrawableAlphaProperty.DRAWABLE_ALPHA_COMPAT, 255);
|
||||
}
|
||||
ofInt.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { // from class: com.google.android.material.transformation.FabTransformationBehavior.2
|
||||
@Override // android.animation.ValueAnimator.AnimatorUpdateListener
|
||||
public void onAnimationUpdate(ValueAnimator valueAnimator) {
|
||||
view2.invalidate();
|
||||
}
|
||||
});
|
||||
fabTransformationSpec.timings.getTiming("iconFade").apply(ofInt);
|
||||
list.add(ofInt);
|
||||
list2.add(new AnimatorListenerAdapter() { // from class: com.google.android.material.transformation.FabTransformationBehavior.3
|
||||
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
|
||||
public void onAnimationStart(Animator animator) {
|
||||
circularRevealWidget.setCircularRevealOverlayDrawable(drawable);
|
||||
}
|
||||
|
||||
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
|
||||
public void onAnimationEnd(Animator animator) {
|
||||
circularRevealWidget.setCircularRevealOverlayDrawable(null);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX WARN: Multi-variable type inference failed */
|
||||
private void createExpansionAnimation(View view, View view2, boolean z, boolean z2, FabTransformationSpec fabTransformationSpec, float f, float f2, List<Animator> list, List<Animator.AnimatorListener> list2) {
|
||||
Animator animator;
|
||||
if (view2 instanceof CircularRevealWidget) {
|
||||
final CircularRevealWidget circularRevealWidget = (CircularRevealWidget) view2;
|
||||
float calculateRevealCenterX = calculateRevealCenterX(view, view2, fabTransformationSpec.positioning);
|
||||
float calculateRevealCenterY = calculateRevealCenterY(view, view2, fabTransformationSpec.positioning);
|
||||
((FloatingActionButton) view).getContentRect(this.tmpRect);
|
||||
float width = this.tmpRect.width() / 2.0f;
|
||||
MotionTiming timing = fabTransformationSpec.timings.getTiming("expansion");
|
||||
if (z) {
|
||||
if (!z2) {
|
||||
circularRevealWidget.setRevealInfo(new CircularRevealWidget.RevealInfo(calculateRevealCenterX, calculateRevealCenterY, width));
|
||||
}
|
||||
if (z2) {
|
||||
width = circularRevealWidget.getRevealInfo().radius;
|
||||
}
|
||||
animator = CircularRevealCompat.createCircularReveal(circularRevealWidget, calculateRevealCenterX, calculateRevealCenterY, MathUtils.distanceToFurthestCorner(calculateRevealCenterX, calculateRevealCenterY, 0.0f, 0.0f, f, f2));
|
||||
animator.addListener(new AnimatorListenerAdapter() { // from class: com.google.android.material.transformation.FabTransformationBehavior.4
|
||||
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
|
||||
public void onAnimationEnd(Animator animator2) {
|
||||
CircularRevealWidget.RevealInfo revealInfo = circularRevealWidget.getRevealInfo();
|
||||
revealInfo.radius = Float.MAX_VALUE;
|
||||
circularRevealWidget.setRevealInfo(revealInfo);
|
||||
}
|
||||
});
|
||||
createPreFillRadialExpansion(view2, timing.getDelay(), (int) calculateRevealCenterX, (int) calculateRevealCenterY, width, list);
|
||||
} else {
|
||||
float f3 = circularRevealWidget.getRevealInfo().radius;
|
||||
Animator createCircularReveal = CircularRevealCompat.createCircularReveal(circularRevealWidget, calculateRevealCenterX, calculateRevealCenterY, width);
|
||||
int i = (int) calculateRevealCenterX;
|
||||
int i2 = (int) calculateRevealCenterY;
|
||||
createPreFillRadialExpansion(view2, timing.getDelay(), i, i2, f3, list);
|
||||
createPostFillRadialExpansion(view2, timing.getDelay(), timing.getDuration(), fabTransformationSpec.timings.getTotalDuration(), i, i2, width, list);
|
||||
animator = createCircularReveal;
|
||||
}
|
||||
timing.apply(animator);
|
||||
list.add(animator);
|
||||
list2.add(CircularRevealCompat.createCircularRevealListener(circularRevealWidget));
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX WARN: Multi-variable type inference failed */
|
||||
private void createColorAnimation(View view, View view2, boolean z, boolean z2, FabTransformationSpec fabTransformationSpec, List<Animator> list, List<Animator.AnimatorListener> list2) {
|
||||
ObjectAnimator ofInt;
|
||||
if (view2 instanceof CircularRevealWidget) {
|
||||
CircularRevealWidget circularRevealWidget = (CircularRevealWidget) view2;
|
||||
int backgroundTint = getBackgroundTint(view);
|
||||
int i = 16777215 & backgroundTint;
|
||||
if (z) {
|
||||
if (!z2) {
|
||||
circularRevealWidget.setCircularRevealScrimColor(backgroundTint);
|
||||
}
|
||||
ofInt = ObjectAnimator.ofInt(circularRevealWidget, CircularRevealWidget.CircularRevealScrimColorProperty.CIRCULAR_REVEAL_SCRIM_COLOR, i);
|
||||
} else {
|
||||
ofInt = ObjectAnimator.ofInt(circularRevealWidget, CircularRevealWidget.CircularRevealScrimColorProperty.CIRCULAR_REVEAL_SCRIM_COLOR, backgroundTint);
|
||||
}
|
||||
ofInt.setEvaluator(ArgbEvaluatorCompat.getInstance());
|
||||
fabTransformationSpec.timings.getTiming(TypedValues.Custom.S_COLOR).apply(ofInt);
|
||||
list.add(ofInt);
|
||||
}
|
||||
}
|
||||
|
||||
private void createChildrenFadeAnimation(View view, View view2, boolean z, boolean z2, FabTransformationSpec fabTransformationSpec, List<Animator> list, List<Animator.AnimatorListener> list2) {
|
||||
ViewGroup calculateChildContentContainer;
|
||||
ObjectAnimator ofFloat;
|
||||
if (view2 instanceof ViewGroup) {
|
||||
if (((view2 instanceof CircularRevealWidget) && CircularRevealHelper.STRATEGY == 0) || (calculateChildContentContainer = calculateChildContentContainer(view2)) == null) {
|
||||
return;
|
||||
}
|
||||
if (z) {
|
||||
if (!z2) {
|
||||
ChildrenAlphaProperty.CHILDREN_ALPHA.set(calculateChildContentContainer, Float.valueOf(0.0f));
|
||||
}
|
||||
ofFloat = ObjectAnimator.ofFloat(calculateChildContentContainer, ChildrenAlphaProperty.CHILDREN_ALPHA, 1.0f);
|
||||
} else {
|
||||
ofFloat = ObjectAnimator.ofFloat(calculateChildContentContainer, ChildrenAlphaProperty.CHILDREN_ALPHA, 0.0f);
|
||||
}
|
||||
fabTransformationSpec.timings.getTiming("contentFade").apply(ofFloat);
|
||||
list.add(ofFloat);
|
||||
}
|
||||
}
|
||||
|
||||
private Pair<MotionTiming, MotionTiming> calculateMotionTiming(float f, float f2, boolean z, FabTransformationSpec fabTransformationSpec) {
|
||||
MotionTiming timing;
|
||||
MotionTiming timing2;
|
||||
if (f == 0.0f || f2 == 0.0f) {
|
||||
timing = fabTransformationSpec.timings.getTiming("translationXLinear");
|
||||
timing2 = fabTransformationSpec.timings.getTiming("translationYLinear");
|
||||
} else if ((z && f2 < 0.0f) || (!z && f2 > 0.0f)) {
|
||||
timing = fabTransformationSpec.timings.getTiming("translationXCurveUpwards");
|
||||
timing2 = fabTransformationSpec.timings.getTiming("translationYCurveUpwards");
|
||||
} else {
|
||||
timing = fabTransformationSpec.timings.getTiming("translationXCurveDownwards");
|
||||
timing2 = fabTransformationSpec.timings.getTiming("translationYCurveDownwards");
|
||||
}
|
||||
return new Pair<>(timing, timing2);
|
||||
}
|
||||
|
||||
private float calculateTranslationX(View view, View view2, Positioning positioning) {
|
||||
float centerX;
|
||||
float centerX2;
|
||||
float f;
|
||||
RectF rectF = this.tmpRectF1;
|
||||
RectF rectF2 = this.tmpRectF2;
|
||||
calculateDependencyWindowBounds(view, rectF);
|
||||
calculateWindowBounds(view2, rectF2);
|
||||
int i = positioning.gravity & 7;
|
||||
if (i == 1) {
|
||||
centerX = rectF2.centerX();
|
||||
centerX2 = rectF.centerX();
|
||||
} else if (i == 3) {
|
||||
centerX = rectF2.left;
|
||||
centerX2 = rectF.left;
|
||||
} else if (i == 5) {
|
||||
centerX = rectF2.right;
|
||||
centerX2 = rectF.right;
|
||||
} else {
|
||||
f = 0.0f;
|
||||
return f + positioning.xAdjustment;
|
||||
}
|
||||
f = centerX - centerX2;
|
||||
return f + positioning.xAdjustment;
|
||||
}
|
||||
|
||||
private float calculateTranslationY(View view, View view2, Positioning positioning) {
|
||||
float centerY;
|
||||
float centerY2;
|
||||
float f;
|
||||
RectF rectF = this.tmpRectF1;
|
||||
RectF rectF2 = this.tmpRectF2;
|
||||
calculateDependencyWindowBounds(view, rectF);
|
||||
calculateWindowBounds(view2, rectF2);
|
||||
int i = positioning.gravity & 112;
|
||||
if (i == 16) {
|
||||
centerY = rectF2.centerY();
|
||||
centerY2 = rectF.centerY();
|
||||
} else if (i == 48) {
|
||||
centerY = rectF2.top;
|
||||
centerY2 = rectF.top;
|
||||
} else if (i == 80) {
|
||||
centerY = rectF2.bottom;
|
||||
centerY2 = rectF.bottom;
|
||||
} else {
|
||||
f = 0.0f;
|
||||
return f + positioning.yAdjustment;
|
||||
}
|
||||
f = centerY - centerY2;
|
||||
return f + positioning.yAdjustment;
|
||||
}
|
||||
|
||||
private void calculateWindowBounds(View view, RectF rectF) {
|
||||
rectF.set(0.0f, 0.0f, view.getWidth(), view.getHeight());
|
||||
view.getLocationInWindow(this.tmpArray);
|
||||
rectF.offsetTo(r0[0], r0[1]);
|
||||
rectF.offset((int) (-view.getTranslationX()), (int) (-view.getTranslationY()));
|
||||
}
|
||||
|
||||
private void calculateDependencyWindowBounds(View view, RectF rectF) {
|
||||
calculateWindowBounds(view, rectF);
|
||||
rectF.offset(this.dependencyOriginalTranslationX, this.dependencyOriginalTranslationY);
|
||||
}
|
||||
|
||||
private float calculateRevealCenterX(View view, View view2, Positioning positioning) {
|
||||
RectF rectF = this.tmpRectF1;
|
||||
RectF rectF2 = this.tmpRectF2;
|
||||
calculateDependencyWindowBounds(view, rectF);
|
||||
calculateWindowBounds(view2, rectF2);
|
||||
rectF2.offset(-calculateTranslationX(view, view2, positioning), 0.0f);
|
||||
return rectF.centerX() - rectF2.left;
|
||||
}
|
||||
|
||||
private float calculateRevealCenterY(View view, View view2, Positioning positioning) {
|
||||
RectF rectF = this.tmpRectF1;
|
||||
RectF rectF2 = this.tmpRectF2;
|
||||
calculateDependencyWindowBounds(view, rectF);
|
||||
calculateWindowBounds(view2, rectF2);
|
||||
rectF2.offset(0.0f, -calculateTranslationY(view, view2, positioning));
|
||||
return rectF.centerY() - rectF2.top;
|
||||
}
|
||||
|
||||
private void calculateChildVisibleBoundsAtEndOfExpansion(View view, FabTransformationSpec fabTransformationSpec, MotionTiming motionTiming, MotionTiming motionTiming2, float f, float f2, float f3, float f4, RectF rectF) {
|
||||
float calculateValueOfAnimationAtEndOfExpansion = calculateValueOfAnimationAtEndOfExpansion(fabTransformationSpec, motionTiming, f, f3);
|
||||
float calculateValueOfAnimationAtEndOfExpansion2 = calculateValueOfAnimationAtEndOfExpansion(fabTransformationSpec, motionTiming2, f2, f4);
|
||||
Rect rect = this.tmpRect;
|
||||
view.getWindowVisibleDisplayFrame(rect);
|
||||
RectF rectF2 = this.tmpRectF1;
|
||||
rectF2.set(rect);
|
||||
RectF rectF3 = this.tmpRectF2;
|
||||
calculateWindowBounds(view, rectF3);
|
||||
rectF3.offset(calculateValueOfAnimationAtEndOfExpansion, calculateValueOfAnimationAtEndOfExpansion2);
|
||||
rectF3.intersect(rectF2);
|
||||
rectF.set(rectF3);
|
||||
}
|
||||
|
||||
private float calculateValueOfAnimationAtEndOfExpansion(FabTransformationSpec fabTransformationSpec, MotionTiming motionTiming, float f, float f2) {
|
||||
long delay = motionTiming.getDelay();
|
||||
long duration = motionTiming.getDuration();
|
||||
MotionTiming timing = fabTransformationSpec.timings.getTiming("expansion");
|
||||
return AnimationUtils.lerp(f, f2, motionTiming.getInterpolator().getInterpolation((((timing.getDelay() + timing.getDuration()) + 17) - delay) / duration));
|
||||
}
|
||||
|
||||
private ViewGroup calculateChildContentContainer(View view) {
|
||||
View findViewById = view.findViewById(R.id.mtrl_child_content_container);
|
||||
if (findViewById != null) {
|
||||
return toViewGroupOrNull(findViewById);
|
||||
}
|
||||
if ((view instanceof TransformationChildLayout) || (view instanceof TransformationChildCard)) {
|
||||
return toViewGroupOrNull(((ViewGroup) view).getChildAt(0));
|
||||
}
|
||||
return toViewGroupOrNull(view);
|
||||
}
|
||||
|
||||
private ViewGroup toViewGroupOrNull(View view) {
|
||||
if (view instanceof ViewGroup) {
|
||||
return (ViewGroup) view;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private int getBackgroundTint(View view) {
|
||||
ColorStateList backgroundTintList = ViewCompat.getBackgroundTintList(view);
|
||||
if (backgroundTintList != null) {
|
||||
return backgroundTintList.getColorForState(view.getDrawableState(), backgroundTintList.getDefaultColor());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private void createPreFillRadialExpansion(View view, long j, int i, int i2, float f, List<Animator> list) {
|
||||
if (j > 0) {
|
||||
Animator createCircularReveal = ViewAnimationUtils.createCircularReveal(view, i, i2, f, f);
|
||||
createCircularReveal.setStartDelay(0L);
|
||||
createCircularReveal.setDuration(j);
|
||||
list.add(createCircularReveal);
|
||||
}
|
||||
}
|
||||
|
||||
private void createPostFillRadialExpansion(View view, long j, long j2, long j3, int i, int i2, float f, List<Animator> list) {
|
||||
long j4 = j + j2;
|
||||
if (j4 < j3) {
|
||||
Animator createCircularReveal = ViewAnimationUtils.createCircularReveal(view, i, i2, f, f);
|
||||
createCircularReveal.setStartDelay(j4);
|
||||
createCircularReveal.setDuration(j3 - j4);
|
||||
list.add(createCircularReveal);
|
||||
}
|
||||
}
|
||||
|
||||
protected static class FabTransformationSpec {
|
||||
public Positioning positioning;
|
||||
public MotionSpec timings;
|
||||
|
||||
protected FabTransformationSpec() {
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,89 @@
|
||||
package com.google.android.material.transformation;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.animation.AnimatorSet;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Property;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||
import com.google.android.material.animation.AnimatorSetCompat;
|
||||
import com.google.android.material.animation.MotionTiming;
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Deprecated
|
||||
/* loaded from: classes.dex */
|
||||
public class FabTransformationScrimBehavior extends ExpandableTransformationBehavior {
|
||||
public static final long COLLAPSE_DELAY = 0;
|
||||
public static final long COLLAPSE_DURATION = 150;
|
||||
public static final long EXPAND_DELAY = 75;
|
||||
public static final long EXPAND_DURATION = 150;
|
||||
private final MotionTiming collapseTiming;
|
||||
private final MotionTiming expandTiming;
|
||||
|
||||
public FabTransformationScrimBehavior() {
|
||||
this.expandTiming = new MotionTiming(75L, 150L);
|
||||
this.collapseTiming = new MotionTiming(0L, 150L);
|
||||
}
|
||||
|
||||
public FabTransformationScrimBehavior(Context context, AttributeSet attributeSet) {
|
||||
super(context, attributeSet);
|
||||
this.expandTiming = new MotionTiming(75L, 150L);
|
||||
this.collapseTiming = new MotionTiming(0L, 150L);
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.transformation.ExpandableBehavior, androidx.coordinatorlayout.widget.CoordinatorLayout.Behavior
|
||||
public boolean layoutDependsOn(CoordinatorLayout coordinatorLayout, View view, View view2) {
|
||||
return view2 instanceof FloatingActionButton;
|
||||
}
|
||||
|
||||
@Override // androidx.coordinatorlayout.widget.CoordinatorLayout.Behavior
|
||||
public boolean onTouchEvent(CoordinatorLayout coordinatorLayout, View view, MotionEvent motionEvent) {
|
||||
return super.onTouchEvent(coordinatorLayout, view, motionEvent);
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.transformation.ExpandableTransformationBehavior
|
||||
protected AnimatorSet onCreateExpandedStateChangeAnimation(View view, final View view2, final boolean z, boolean z2) {
|
||||
ArrayList arrayList = new ArrayList();
|
||||
createScrimAnimation(view2, z, z2, arrayList, new ArrayList());
|
||||
AnimatorSet animatorSet = new AnimatorSet();
|
||||
AnimatorSetCompat.playTogether(animatorSet, arrayList);
|
||||
animatorSet.addListener(new AnimatorListenerAdapter() { // from class: com.google.android.material.transformation.FabTransformationScrimBehavior.1
|
||||
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
|
||||
public void onAnimationStart(Animator animator) {
|
||||
if (z) {
|
||||
view2.setVisibility(0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
|
||||
public void onAnimationEnd(Animator animator) {
|
||||
if (z) {
|
||||
return;
|
||||
}
|
||||
view2.setVisibility(4);
|
||||
}
|
||||
});
|
||||
return animatorSet;
|
||||
}
|
||||
|
||||
private void createScrimAnimation(View view, boolean z, boolean z2, List<Animator> list, List<Animator.AnimatorListener> list2) {
|
||||
ObjectAnimator ofFloat;
|
||||
MotionTiming motionTiming = z ? this.expandTiming : this.collapseTiming;
|
||||
if (z) {
|
||||
if (!z2) {
|
||||
view.setAlpha(0.0f);
|
||||
}
|
||||
ofFloat = ObjectAnimator.ofFloat(view, (Property<View, Float>) View.ALPHA, 1.0f);
|
||||
} else {
|
||||
ofFloat = ObjectAnimator.ofFloat(view, (Property<View, Float>) View.ALPHA, 0.0f);
|
||||
}
|
||||
motionTiming.apply(ofFloat);
|
||||
list.add(ofFloat);
|
||||
}
|
||||
}
|
@ -0,0 +1,77 @@
|
||||
package com.google.android.material.transformation;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.view.ViewParent;
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import com.google.android.material.R;
|
||||
import com.google.android.material.animation.MotionSpec;
|
||||
import com.google.android.material.animation.Positioning;
|
||||
import com.google.android.material.transformation.FabTransformationBehavior;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Deprecated
|
||||
/* loaded from: classes.dex */
|
||||
public class FabTransformationSheetBehavior extends FabTransformationBehavior {
|
||||
private Map<View, Integer> importantForAccessibilityMap;
|
||||
|
||||
public FabTransformationSheetBehavior() {
|
||||
}
|
||||
|
||||
public FabTransformationSheetBehavior(Context context, AttributeSet attributeSet) {
|
||||
super(context, attributeSet);
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.transformation.FabTransformationBehavior
|
||||
protected FabTransformationBehavior.FabTransformationSpec onCreateMotionSpec(Context context, boolean z) {
|
||||
int i;
|
||||
if (z) {
|
||||
i = R.animator.mtrl_fab_transformation_sheet_expand_spec;
|
||||
} else {
|
||||
i = R.animator.mtrl_fab_transformation_sheet_collapse_spec;
|
||||
}
|
||||
FabTransformationBehavior.FabTransformationSpec fabTransformationSpec = new FabTransformationBehavior.FabTransformationSpec();
|
||||
fabTransformationSpec.timings = MotionSpec.createFromResource(context, i);
|
||||
fabTransformationSpec.positioning = new Positioning(17, 0.0f, 0.0f);
|
||||
return fabTransformationSpec;
|
||||
}
|
||||
|
||||
@Override // com.google.android.material.transformation.ExpandableTransformationBehavior, com.google.android.material.transformation.ExpandableBehavior
|
||||
protected boolean onExpandedStateChange(View view, View view2, boolean z, boolean z2) {
|
||||
updateImportantForAccessibility(view2, z);
|
||||
return super.onExpandedStateChange(view, view2, z, z2);
|
||||
}
|
||||
|
||||
private void updateImportantForAccessibility(View view, boolean z) {
|
||||
ViewParent parent = view.getParent();
|
||||
if (parent instanceof CoordinatorLayout) {
|
||||
CoordinatorLayout coordinatorLayout = (CoordinatorLayout) parent;
|
||||
int childCount = coordinatorLayout.getChildCount();
|
||||
if (z) {
|
||||
this.importantForAccessibilityMap = new HashMap(childCount);
|
||||
}
|
||||
for (int i = 0; i < childCount; i++) {
|
||||
View childAt = coordinatorLayout.getChildAt(i);
|
||||
boolean z2 = (childAt.getLayoutParams() instanceof CoordinatorLayout.LayoutParams) && (((CoordinatorLayout.LayoutParams) childAt.getLayoutParams()).getBehavior() instanceof FabTransformationScrimBehavior);
|
||||
if (childAt != view && !z2) {
|
||||
if (!z) {
|
||||
Map<View, Integer> map = this.importantForAccessibilityMap;
|
||||
if (map != null && map.containsKey(childAt)) {
|
||||
ViewCompat.setImportantForAccessibility(childAt, this.importantForAccessibilityMap.get(childAt).intValue());
|
||||
}
|
||||
} else {
|
||||
this.importantForAccessibilityMap.put(childAt, Integer.valueOf(childAt.getImportantForAccessibility()));
|
||||
ViewCompat.setImportantForAccessibility(childAt, 4);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (z) {
|
||||
return;
|
||||
}
|
||||
this.importantForAccessibilityMap = null;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package com.google.android.material.transformation;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import com.google.android.material.circularreveal.cardview.CircularRevealCardView;
|
||||
|
||||
@Deprecated
|
||||
/* loaded from: classes.dex */
|
||||
public class TransformationChildCard extends CircularRevealCardView {
|
||||
public TransformationChildCard(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public TransformationChildCard(Context context, AttributeSet attributeSet) {
|
||||
super(context, attributeSet);
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package com.google.android.material.transformation;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import com.google.android.material.circularreveal.CircularRevealFrameLayout;
|
||||
|
||||
@Deprecated
|
||||
/* loaded from: classes.dex */
|
||||
public class TransformationChildLayout extends CircularRevealFrameLayout {
|
||||
public TransformationChildLayout(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public TransformationChildLayout(Context context, AttributeSet attributeSet) {
|
||||
super(context, attributeSet);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user