ADD week 5

This commit is contained in:
2025-03-31 16:33:42 +02:00
parent 86f265f22d
commit bf645048e6
4927 changed files with 544053 additions and 0 deletions

View File

@ -0,0 +1,64 @@
package com.google.android.material.motion;
import android.animation.TimeInterpolator;
import android.content.Context;
import android.util.Log;
import android.view.View;
import androidx.activity.BackEventCompat;
import androidx.core.view.animation.PathInterpolatorCompat;
import com.google.android.material.R;
/* loaded from: classes.dex */
public abstract class MaterialBackAnimationHelper<V extends View> {
private static final int CANCEL_DURATION_DEFAULT = 100;
private static final int HIDE_DURATION_MAX_DEFAULT = 300;
private static final int HIDE_DURATION_MIN_DEFAULT = 150;
private static final String TAG = "MaterialBackHelper";
private BackEventCompat backEvent;
protected final int cancelDuration;
protected final int hideDurationMax;
protected final int hideDurationMin;
private final TimeInterpolator progressInterpolator;
protected final V view;
public BackEventCompat onHandleBackInvoked() {
BackEventCompat backEventCompat = this.backEvent;
this.backEvent = null;
return backEventCompat;
}
protected void onStartBackProgress(BackEventCompat backEventCompat) {
this.backEvent = backEventCompat;
}
public MaterialBackAnimationHelper(V v) {
this.view = v;
Context context = v.getContext();
this.progressInterpolator = MotionUtils.resolveThemeInterpolator(context, R.attr.motionEasingStandardDecelerateInterpolator, PathInterpolatorCompat.create(0.0f, 0.0f, 0.0f, 1.0f));
this.hideDurationMax = MotionUtils.resolveThemeDuration(context, R.attr.motionDurationMedium2, 300);
this.hideDurationMin = MotionUtils.resolveThemeDuration(context, R.attr.motionDurationShort3, HIDE_DURATION_MIN_DEFAULT);
this.cancelDuration = MotionUtils.resolveThemeDuration(context, R.attr.motionDurationShort2, 100);
}
protected float interpolateProgress(float f) {
return this.progressInterpolator.getInterpolation(f);
}
protected BackEventCompat onUpdateBackProgress(BackEventCompat backEventCompat) {
if (this.backEvent == null) {
Log.w(TAG, "Must call startBackProgress() before updateBackProgress()");
}
BackEventCompat backEventCompat2 = this.backEvent;
this.backEvent = backEventCompat;
return backEventCompat2;
}
protected BackEventCompat onCancelBackProgress() {
if (this.backEvent == null) {
Log.w(TAG, "Must call startBackProgress() and updateBackProgress() before cancelBackProgress()");
}
BackEventCompat backEventCompat = this.backEvent;
this.backEvent = null;
return backEventCompat;
}
}

View File

@ -0,0 +1,14 @@
package com.google.android.material.motion;
import androidx.activity.BackEventCompat;
/* loaded from: classes.dex */
public interface MaterialBackHandler {
void cancelBackProgress();
void handleBackInvoked();
void startBackProgress(BackEventCompat backEventCompat);
void updateBackProgress(BackEventCompat backEventCompat);
}

View File

@ -0,0 +1,172 @@
package com.google.android.material.motion;
import android.os.Build;
import android.view.View;
import android.window.BackEvent;
import android.window.OnBackAnimationCallback;
import android.window.OnBackInvokedCallback;
import android.window.OnBackInvokedDispatcher;
import androidx.activity.BackEventCompat;
import java.util.Objects;
/* loaded from: classes.dex */
public final class MaterialBackOrchestrator {
private final BackCallbackDelegate backCallbackDelegate;
private final MaterialBackHandler backHandler;
private final View view;
private interface BackCallbackDelegate {
void startListeningForBackCallbacks(MaterialBackHandler materialBackHandler, View view, boolean z);
void stopListeningForBackCallbacks(View view);
}
public boolean shouldListenForBackCallbacks() {
return this.backCallbackDelegate != null;
}
public <T extends View & MaterialBackHandler> MaterialBackOrchestrator(T t) {
this(t, t);
}
public MaterialBackOrchestrator(MaterialBackHandler materialBackHandler, View view) {
this.backCallbackDelegate = createBackCallbackDelegate();
this.backHandler = materialBackHandler;
this.view = view;
}
public void startListeningForBackCallbacksWithPriorityOverlay() {
startListeningForBackCallbacks(true);
}
public void startListeningForBackCallbacks() {
startListeningForBackCallbacks(false);
}
private void startListeningForBackCallbacks(boolean z) {
BackCallbackDelegate backCallbackDelegate = this.backCallbackDelegate;
if (backCallbackDelegate != null) {
backCallbackDelegate.startListeningForBackCallbacks(this.backHandler, this.view, z);
}
}
public void stopListeningForBackCallbacks() {
BackCallbackDelegate backCallbackDelegate = this.backCallbackDelegate;
if (backCallbackDelegate != null) {
backCallbackDelegate.stopListeningForBackCallbacks(this.view);
}
}
private static BackCallbackDelegate createBackCallbackDelegate() {
if (Build.VERSION.SDK_INT >= 34) {
return new Api34BackCallbackDelegate();
}
if (Build.VERSION.SDK_INT >= 33) {
return new Api33BackCallbackDelegate();
}
return null;
}
private static class Api34BackCallbackDelegate extends Api33BackCallbackDelegate {
private Api34BackCallbackDelegate() {
super();
}
@Override // com.google.android.material.motion.MaterialBackOrchestrator.Api33BackCallbackDelegate
OnBackInvokedCallback createOnBackInvokedCallback(final MaterialBackHandler materialBackHandler) {
return new OnBackAnimationCallback() { // from class: com.google.android.material.motion.MaterialBackOrchestrator.Api34BackCallbackDelegate.1
@Override // android.window.OnBackAnimationCallback
public void onBackStarted(BackEvent backEvent) {
if (Api34BackCallbackDelegate.this.isListeningForBackCallbacks()) {
materialBackHandler.startBackProgress(new BackEventCompat(backEvent));
}
}
@Override // android.window.OnBackAnimationCallback
public void onBackProgressed(BackEvent backEvent) {
if (Api34BackCallbackDelegate.this.isListeningForBackCallbacks()) {
materialBackHandler.updateBackProgress(new BackEventCompat(backEvent));
}
}
@Override // android.window.OnBackInvokedCallback
public void onBackInvoked() {
materialBackHandler.handleBackInvoked();
}
@Override // android.window.OnBackAnimationCallback
public void onBackCancelled() {
if (Api34BackCallbackDelegate.this.isListeningForBackCallbacks()) {
materialBackHandler.cancelBackProgress();
}
}
};
}
}
private static class Api33BackCallbackDelegate implements BackCallbackDelegate {
private OnBackInvokedCallback onBackInvokedCallback;
boolean isListeningForBackCallbacks() {
return this.onBackInvokedCallback != null;
}
private Api33BackCallbackDelegate() {
}
/* JADX WARN: Code restructure failed: missing block: B:5:0x0005, code lost:
r3 = r3.findOnBackInvokedDispatcher();
*/
@Override // com.google.android.material.motion.MaterialBackOrchestrator.BackCallbackDelegate
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public void startListeningForBackCallbacks(com.google.android.material.motion.MaterialBackHandler r2, android.view.View r3, boolean r4) {
/*
r1 = this;
android.window.OnBackInvokedCallback r0 = r1.onBackInvokedCallback
if (r0 == 0) goto L5
return
L5:
android.window.OnBackInvokedDispatcher r3 = kotlin.io.path.PathTreeWalk$$ExternalSyntheticApiModelOutline0.m(r3)
if (r3 != 0) goto Lc
return
Lc:
android.window.OnBackInvokedCallback r2 = r1.createOnBackInvokedCallback(r2)
r1.onBackInvokedCallback = r2
if (r4 == 0) goto L18
r4 = 1000000(0xf4240, float:1.401298E-39)
goto L19
L18:
r4 = 0
L19:
androidx.activity.ComponentDialog$$ExternalSyntheticApiModelOutline0.m(r3, r4, r2)
return
*/
throw new UnsupportedOperationException("Method not decompiled: com.google.android.material.motion.MaterialBackOrchestrator.Api33BackCallbackDelegate.startListeningForBackCallbacks(com.google.android.material.motion.MaterialBackHandler, android.view.View, boolean):void");
}
@Override // com.google.android.material.motion.MaterialBackOrchestrator.BackCallbackDelegate
public void stopListeningForBackCallbacks(View view) {
OnBackInvokedDispatcher findOnBackInvokedDispatcher;
findOnBackInvokedDispatcher = view.findOnBackInvokedDispatcher();
if (findOnBackInvokedDispatcher == null) {
return;
}
findOnBackInvokedDispatcher.unregisterOnBackInvokedCallback(this.onBackInvokedCallback);
this.onBackInvokedCallback = null;
}
OnBackInvokedCallback createOnBackInvokedCallback(final MaterialBackHandler materialBackHandler) {
Objects.requireNonNull(materialBackHandler);
return new OnBackInvokedCallback() { // from class: com.google.android.material.motion.MaterialBackOrchestrator$Api33BackCallbackDelegate$$ExternalSyntheticLambda1
@Override // android.window.OnBackInvokedCallback
public final void onBackInvoked() {
MaterialBackHandler.this.handleBackInvoked();
}
};
}
}
}

View File

@ -0,0 +1,110 @@
package com.google.android.material.motion;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.content.res.Resources;
import android.util.Property;
import android.view.View;
import android.view.ViewGroup;
import androidx.activity.BackEventCompat;
import androidx.interpolator.view.animation.FastOutSlowInInterpolator;
import com.google.android.material.R;
import com.google.android.material.animation.AnimationUtils;
/* loaded from: classes.dex */
public class MaterialBottomContainerBackHelper extends MaterialBackAnimationHelper<View> {
private final float maxScaleXDistance;
private final float maxScaleYDistance;
public MaterialBottomContainerBackHelper(View view) {
super(view);
Resources resources = view.getResources();
this.maxScaleXDistance = resources.getDimension(R.dimen.m3_back_progress_bottom_container_max_scale_x_distance);
this.maxScaleYDistance = resources.getDimension(R.dimen.m3_back_progress_bottom_container_max_scale_y_distance);
}
public void startBackProgress(BackEventCompat backEventCompat) {
super.onStartBackProgress(backEventCompat);
}
public void updateBackProgress(BackEventCompat backEventCompat) {
if (super.onUpdateBackProgress(backEventCompat) == null) {
return;
}
updateBackProgress(backEventCompat.getProgress());
}
public void updateBackProgress(float f) {
float interpolateProgress = interpolateProgress(f);
float width = this.view.getWidth();
float height = this.view.getHeight();
if (width <= 0.0f || height <= 0.0f) {
return;
}
float f2 = this.maxScaleXDistance / width;
float f3 = this.maxScaleYDistance / height;
float lerp = 1.0f - AnimationUtils.lerp(0.0f, f2, interpolateProgress);
float lerp2 = 1.0f - AnimationUtils.lerp(0.0f, f3, interpolateProgress);
this.view.setScaleX(lerp);
this.view.setPivotY(height);
this.view.setScaleY(lerp2);
if (this.view instanceof ViewGroup) {
ViewGroup viewGroup = (ViewGroup) this.view;
for (int i = 0; i < viewGroup.getChildCount(); i++) {
View childAt = viewGroup.getChildAt(i);
childAt.setPivotY(-childAt.getTop());
childAt.setScaleY(lerp2 != 0.0f ? lerp / lerp2 : 1.0f);
}
}
}
public void finishBackProgressPersistent(BackEventCompat backEventCompat, Animator.AnimatorListener animatorListener) {
Animator createResetScaleAnimator = createResetScaleAnimator();
createResetScaleAnimator.setDuration(AnimationUtils.lerp(this.hideDurationMax, this.hideDurationMin, backEventCompat.getProgress()));
if (animatorListener != null) {
createResetScaleAnimator.addListener(animatorListener);
}
createResetScaleAnimator.start();
}
public void finishBackProgressNotPersistent(BackEventCompat backEventCompat, Animator.AnimatorListener animatorListener) {
ObjectAnimator ofFloat = ObjectAnimator.ofFloat(this.view, (Property<V, Float>) View.TRANSLATION_Y, this.view.getHeight() * this.view.getScaleY());
ofFloat.setInterpolator(new FastOutSlowInInterpolator());
ofFloat.setDuration(AnimationUtils.lerp(this.hideDurationMax, this.hideDurationMin, backEventCompat.getProgress()));
ofFloat.addListener(new AnimatorListenerAdapter() { // from class: com.google.android.material.motion.MaterialBottomContainerBackHelper.1
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
public void onAnimationEnd(Animator animator) {
MaterialBottomContainerBackHelper.this.view.setTranslationY(0.0f);
MaterialBottomContainerBackHelper.this.updateBackProgress(0.0f);
}
});
if (animatorListener != null) {
ofFloat.addListener(animatorListener);
}
ofFloat.start();
}
public void cancelBackProgress() {
if (super.onCancelBackProgress() == null) {
return;
}
Animator createResetScaleAnimator = createResetScaleAnimator();
createResetScaleAnimator.setDuration(this.cancelDuration);
createResetScaleAnimator.start();
}
private Animator createResetScaleAnimator() {
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.playTogether(ObjectAnimator.ofFloat(this.view, (Property<V, Float>) View.SCALE_X, 1.0f), ObjectAnimator.ofFloat(this.view, (Property<V, Float>) View.SCALE_Y, 1.0f));
if (this.view instanceof ViewGroup) {
ViewGroup viewGroup = (ViewGroup) this.view;
for (int i = 0; i < viewGroup.getChildCount(); i++) {
animatorSet.playTogether(ObjectAnimator.ofFloat(viewGroup.getChildAt(i), (Property<View, Float>) View.SCALE_Y, 1.0f));
}
}
animatorSet.setInterpolator(new FastOutSlowInInterpolator());
return animatorSet;
}
}

View File

@ -0,0 +1,199 @@
package com.google.android.material.motion;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.content.res.Resources;
import android.graphics.Rect;
import android.util.Property;
import android.view.RoundedCorner;
import android.view.View;
import android.view.WindowInsets;
import androidx.activity.BackEventCompat;
import com.google.android.material.R;
import com.google.android.material.animation.AnimationUtils;
import com.google.android.material.internal.ClippableRoundedCornerLayout;
import com.google.android.material.internal.ViewUtils;
/* loaded from: classes.dex */
public class MaterialMainContainerBackHelper extends MaterialBackAnimationHelper<View> {
private static final float MIN_SCALE = 0.9f;
private Integer expandedCornerSize;
private Rect initialHideFromClipBounds;
private Rect initialHideToClipBounds;
private float initialTouchY;
private final float maxTranslationY;
private final float minEdgeGap;
private void resetInitialValues() {
this.initialTouchY = 0.0f;
this.initialHideToClipBounds = null;
this.initialHideFromClipBounds = null;
}
public Rect getInitialHideFromClipBounds() {
return this.initialHideFromClipBounds;
}
public Rect getInitialHideToClipBounds() {
return this.initialHideToClipBounds;
}
public MaterialMainContainerBackHelper(View view) {
super(view);
Resources resources = view.getResources();
this.minEdgeGap = resources.getDimension(R.dimen.m3_back_progress_main_container_min_edge_gap);
this.maxTranslationY = resources.getDimension(R.dimen.m3_back_progress_main_container_max_translation_y);
}
public void startBackProgress(BackEventCompat backEventCompat, View view) {
super.onStartBackProgress(backEventCompat);
startBackProgress(backEventCompat.getTouchY(), view);
}
public void startBackProgress(float f, View view) {
this.initialHideToClipBounds = ViewUtils.calculateRectFromBounds(this.view);
if (view != null) {
this.initialHideFromClipBounds = ViewUtils.calculateOffsetRectFromBounds(this.view, view);
}
this.initialTouchY = f;
}
public void updateBackProgress(BackEventCompat backEventCompat, View view, float f) {
if (super.onUpdateBackProgress(backEventCompat) == null) {
return;
}
if (view != null && view.getVisibility() != 4) {
view.setVisibility(4);
}
updateBackProgress(backEventCompat.getProgress(), backEventCompat.getSwipeEdge() == 0, backEventCompat.getTouchY(), f);
}
public void updateBackProgress(float f, boolean z, float f2, float f3) {
float interpolateProgress = interpolateProgress(f);
float width = this.view.getWidth();
float height = this.view.getHeight();
if (width <= 0.0f || height <= 0.0f) {
return;
}
float lerp = AnimationUtils.lerp(1.0f, MIN_SCALE, interpolateProgress);
float lerp2 = AnimationUtils.lerp(0.0f, Math.max(0.0f, ((width - (MIN_SCALE * width)) / 2.0f) - this.minEdgeGap), interpolateProgress) * (z ? 1 : -1);
float min = Math.min(Math.max(0.0f, ((height - (lerp * height)) / 2.0f) - this.minEdgeGap), this.maxTranslationY);
float f4 = f2 - this.initialTouchY;
float lerp3 = AnimationUtils.lerp(0.0f, min, Math.abs(f4) / height) * Math.signum(f4);
this.view.setScaleX(lerp);
this.view.setScaleY(lerp);
this.view.setTranslationX(lerp2);
this.view.setTranslationY(lerp3);
if (this.view instanceof ClippableRoundedCornerLayout) {
((ClippableRoundedCornerLayout) this.view).updateCornerRadius(AnimationUtils.lerp(getExpandedCornerSize(), f3, interpolateProgress));
}
}
public void finishBackProgress(long j, View view) {
AnimatorSet createResetScaleAndTranslationAnimator = createResetScaleAndTranslationAnimator(view);
createResetScaleAndTranslationAnimator.setDuration(j);
createResetScaleAndTranslationAnimator.start();
resetInitialValues();
}
public void cancelBackProgress(View view) {
if (super.onCancelBackProgress() == null) {
return;
}
AnimatorSet createResetScaleAndTranslationAnimator = createResetScaleAndTranslationAnimator(view);
if (this.view instanceof ClippableRoundedCornerLayout) {
createResetScaleAndTranslationAnimator.playTogether(createCornerAnimator((ClippableRoundedCornerLayout) this.view));
}
createResetScaleAndTranslationAnimator.setDuration(this.cancelDuration);
createResetScaleAndTranslationAnimator.start();
resetInitialValues();
}
private AnimatorSet createResetScaleAndTranslationAnimator(final View view) {
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.playTogether(ObjectAnimator.ofFloat(this.view, (Property<V, Float>) View.SCALE_X, 1.0f), ObjectAnimator.ofFloat(this.view, (Property<V, Float>) View.SCALE_Y, 1.0f), ObjectAnimator.ofFloat(this.view, (Property<V, Float>) View.TRANSLATION_X, 0.0f), ObjectAnimator.ofFloat(this.view, (Property<V, Float>) View.TRANSLATION_Y, 0.0f));
animatorSet.addListener(new AnimatorListenerAdapter() { // from class: com.google.android.material.motion.MaterialMainContainerBackHelper.1
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
public void onAnimationEnd(Animator animator) {
View view2 = view;
if (view2 != null) {
view2.setVisibility(0);
}
}
});
return animatorSet;
}
private ValueAnimator createCornerAnimator(final ClippableRoundedCornerLayout clippableRoundedCornerLayout) {
ValueAnimator ofFloat = ValueAnimator.ofFloat(clippableRoundedCornerLayout.getCornerRadius(), getExpandedCornerSize());
ofFloat.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { // from class: com.google.android.material.motion.MaterialMainContainerBackHelper$$ExternalSyntheticLambda0
@Override // android.animation.ValueAnimator.AnimatorUpdateListener
public final void onAnimationUpdate(ValueAnimator valueAnimator) {
ClippableRoundedCornerLayout.this.updateCornerRadius(((Float) valueAnimator.getAnimatedValue()).floatValue());
}
});
return ofFloat;
}
public int getExpandedCornerSize() {
if (this.expandedCornerSize == null) {
this.expandedCornerSize = Integer.valueOf(isAtTopOfScreen() ? getMaxDeviceCornerRadius() : 0);
}
return this.expandedCornerSize.intValue();
}
private boolean isAtTopOfScreen() {
int[] iArr = new int[2];
this.view.getLocationOnScreen(iArr);
return iArr[1] == 0;
}
/* JADX WARN: Code restructure failed: missing block: B:3:0x0007, code lost:
r0 = r4.view.getRootWindowInsets();
*/
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
private int getMaxDeviceCornerRadius() {
/*
r4 = this;
int r0 = android.os.Build.VERSION.SDK_INT
r1 = 31
r2 = 0
if (r0 < r1) goto L2f
V extends android.view.View r0 = r4.view
android.view.WindowInsets r0 = androidx.tracing.Trace$$ExternalSyntheticApiModelOutline0.m173m(r0)
if (r0 == 0) goto L2f
int r1 = r4.getRoundedCornerRadius(r0, r2)
r2 = 1
int r2 = r4.getRoundedCornerRadius(r0, r2)
int r1 = java.lang.Math.max(r1, r2)
r2 = 3
int r2 = r4.getRoundedCornerRadius(r0, r2)
r3 = 2
int r0 = r4.getRoundedCornerRadius(r0, r3)
int r0 = java.lang.Math.max(r2, r0)
int r0 = java.lang.Math.max(r1, r0)
return r0
L2f:
return r2
*/
throw new UnsupportedOperationException("Method not decompiled: com.google.android.material.motion.MaterialMainContainerBackHelper.getMaxDeviceCornerRadius():int");
}
private int getRoundedCornerRadius(WindowInsets windowInsets, int i) {
RoundedCorner roundedCorner;
int radius;
roundedCorner = windowInsets.getRoundedCorner(i);
if (roundedCorner == null) {
return 0;
}
radius = roundedCorner.getRadius();
return radius;
}
}

View File

@ -0,0 +1,151 @@
package com.google.android.material.motion;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.content.res.Resources;
import android.util.Property;
import android.view.View;
import android.view.ViewGroup;
import androidx.activity.BackEventCompat;
import androidx.core.view.GravityCompat;
import androidx.core.view.ViewCompat;
import androidx.interpolator.view.animation.FastOutSlowInInterpolator;
import com.google.android.material.R;
import com.google.android.material.animation.AnimationUtils;
/* loaded from: classes.dex */
public class MaterialSideContainerBackHelper extends MaterialBackAnimationHelper<View> {
private final float maxScaleXDistanceGrow;
private final float maxScaleXDistanceShrink;
private final float maxScaleYDistance;
public MaterialSideContainerBackHelper(View view) {
super(view);
Resources resources = view.getResources();
this.maxScaleXDistanceShrink = resources.getDimension(R.dimen.m3_back_progress_side_container_max_scale_x_distance_shrink);
this.maxScaleXDistanceGrow = resources.getDimension(R.dimen.m3_back_progress_side_container_max_scale_x_distance_grow);
this.maxScaleYDistance = resources.getDimension(R.dimen.m3_back_progress_side_container_max_scale_y_distance);
}
public void startBackProgress(BackEventCompat backEventCompat) {
super.onStartBackProgress(backEventCompat);
}
public void updateBackProgress(BackEventCompat backEventCompat, int i) {
if (super.onUpdateBackProgress(backEventCompat) == null) {
return;
}
updateBackProgress(backEventCompat.getProgress(), backEventCompat.getSwipeEdge() == 0, i);
}
public void updateBackProgress(float f, boolean z, int i) {
int i2;
float interpolateProgress = interpolateProgress(f);
boolean checkAbsoluteGravity = checkAbsoluteGravity(i, 3);
boolean z2 = z == checkAbsoluteGravity;
int width = this.view.getWidth();
int height = this.view.getHeight();
float f2 = width;
if (f2 > 0.0f) {
float f3 = height;
if (f3 <= 0.0f) {
return;
}
float f4 = this.maxScaleXDistanceShrink / f2;
float f5 = this.maxScaleXDistanceGrow / f2;
float f6 = this.maxScaleYDistance / f3;
V v = this.view;
if (checkAbsoluteGravity) {
f2 = 0.0f;
}
v.setPivotX(f2);
if (!z2) {
f5 = -f4;
}
float lerp = AnimationUtils.lerp(0.0f, f5, interpolateProgress);
float f7 = lerp + 1.0f;
this.view.setScaleX(f7);
float lerp2 = 1.0f - AnimationUtils.lerp(0.0f, f6, interpolateProgress);
this.view.setScaleY(lerp2);
if (this.view instanceof ViewGroup) {
ViewGroup viewGroup = (ViewGroup) this.view;
for (int i3 = 0; i3 < viewGroup.getChildCount(); i3++) {
View childAt = viewGroup.getChildAt(i3);
if (checkAbsoluteGravity) {
i2 = (width - childAt.getRight()) + childAt.getWidth();
} else {
i2 = -childAt.getLeft();
}
childAt.setPivotX(i2);
childAt.setPivotY(-childAt.getTop());
float f8 = z2 ? 1.0f - lerp : 1.0f;
float f9 = lerp2 != 0.0f ? (f7 / lerp2) * f8 : 1.0f;
childAt.setScaleX(f8);
childAt.setScaleY(f9);
}
}
}
}
public void finishBackProgress(BackEventCompat backEventCompat, final int i, Animator.AnimatorListener animatorListener, ValueAnimator.AnimatorUpdateListener animatorUpdateListener) {
final boolean z = backEventCompat.getSwipeEdge() == 0;
boolean checkAbsoluteGravity = checkAbsoluteGravity(i, 3);
float width = (this.view.getWidth() * this.view.getScaleX()) + getEdgeMargin(checkAbsoluteGravity);
V v = this.view;
Property property = View.TRANSLATION_X;
float[] fArr = new float[1];
if (checkAbsoluteGravity) {
width = -width;
}
fArr[0] = width;
ObjectAnimator ofFloat = ObjectAnimator.ofFloat(v, (Property<V, Float>) property, fArr);
if (animatorUpdateListener != null) {
ofFloat.addUpdateListener(animatorUpdateListener);
}
ofFloat.setInterpolator(new FastOutSlowInInterpolator());
ofFloat.setDuration(AnimationUtils.lerp(this.hideDurationMax, this.hideDurationMin, backEventCompat.getProgress()));
ofFloat.addListener(new AnimatorListenerAdapter() { // from class: com.google.android.material.motion.MaterialSideContainerBackHelper.1
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
public void onAnimationEnd(Animator animator) {
MaterialSideContainerBackHelper.this.view.setTranslationX(0.0f);
MaterialSideContainerBackHelper.this.updateBackProgress(0.0f, z, i);
}
});
if (animatorListener != null) {
ofFloat.addListener(animatorListener);
}
ofFloat.start();
}
public void cancelBackProgress() {
if (super.onCancelBackProgress() == null) {
return;
}
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.playTogether(ObjectAnimator.ofFloat(this.view, (Property<V, Float>) View.SCALE_X, 1.0f), ObjectAnimator.ofFloat(this.view, (Property<V, Float>) View.SCALE_Y, 1.0f));
if (this.view instanceof ViewGroup) {
ViewGroup viewGroup = (ViewGroup) this.view;
for (int i = 0; i < viewGroup.getChildCount(); i++) {
animatorSet.playTogether(ObjectAnimator.ofFloat(viewGroup.getChildAt(i), (Property<View, Float>) View.SCALE_Y, 1.0f));
}
}
animatorSet.setDuration(this.cancelDuration);
animatorSet.start();
}
private boolean checkAbsoluteGravity(int i, int i2) {
return (GravityCompat.getAbsoluteGravity(i, ViewCompat.getLayoutDirection(this.view)) & i2) == i2;
}
private int getEdgeMargin(boolean z) {
ViewGroup.LayoutParams layoutParams = this.view.getLayoutParams();
if (!(layoutParams instanceof ViewGroup.MarginLayoutParams)) {
return 0;
}
ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) layoutParams;
return z ? marginLayoutParams.leftMargin : marginLayoutParams.rightMargin;
}
}

View File

@ -0,0 +1,76 @@
package com.google.android.material.motion;
import android.animation.TimeInterpolator;
import android.content.Context;
import android.util.TypedValue;
import android.view.animation.AnimationUtils;
import androidx.core.graphics.PathParser;
import androidx.core.view.animation.PathInterpolatorCompat;
import com.google.android.material.resources.MaterialAttributes;
/* loaded from: classes.dex */
public class MotionUtils {
private static final String EASING_TYPE_CUBIC_BEZIER = "cubic-bezier";
private static final String EASING_TYPE_FORMAT_END = ")";
private static final String EASING_TYPE_FORMAT_START = "(";
private static final String EASING_TYPE_PATH = "path";
private MotionUtils() {
}
public static int resolveThemeDuration(Context context, int i, int i2) {
return MaterialAttributes.resolveInteger(context, i, i2);
}
public static TimeInterpolator resolveThemeInterpolator(Context context, int i, TimeInterpolator timeInterpolator) {
TypedValue typedValue = new TypedValue();
if (!context.getTheme().resolveAttribute(i, typedValue, true)) {
return timeInterpolator;
}
if (typedValue.type != 3) {
throw new IllegalArgumentException("Motion easing theme attribute must be an @interpolator resource for ?attr/motionEasing*Interpolator attributes or a string for ?attr/motionEasing* attributes.");
}
String valueOf = String.valueOf(typedValue.string);
if (isLegacyEasingAttribute(valueOf)) {
return getLegacyThemeInterpolator(valueOf);
}
return AnimationUtils.loadInterpolator(context, typedValue.resourceId);
}
private static TimeInterpolator getLegacyThemeInterpolator(String str) {
if (isLegacyEasingType(str, EASING_TYPE_CUBIC_BEZIER)) {
String[] split = getLegacyEasingContent(str, EASING_TYPE_CUBIC_BEZIER).split(",");
if (split.length != 4) {
throw new IllegalArgumentException("Motion easing theme attribute must have 4 control points if using bezier curve format; instead got: " + split.length);
}
return PathInterpolatorCompat.create(getLegacyControlPoint(split, 0), getLegacyControlPoint(split, 1), getLegacyControlPoint(split, 2), getLegacyControlPoint(split, 3));
}
if (isLegacyEasingType(str, EASING_TYPE_PATH)) {
return PathInterpolatorCompat.create(PathParser.createPathFromPathData(getLegacyEasingContent(str, EASING_TYPE_PATH)));
}
throw new IllegalArgumentException("Invalid motion easing type: " + str);
}
private static boolean isLegacyEasingAttribute(String str) {
return isLegacyEasingType(str, EASING_TYPE_CUBIC_BEZIER) || isLegacyEasingType(str, EASING_TYPE_PATH);
}
private static boolean isLegacyEasingType(String str, String str2) {
StringBuilder sb = new StringBuilder();
sb.append(str2);
sb.append(EASING_TYPE_FORMAT_START);
return str.startsWith(sb.toString()) && str.endsWith(EASING_TYPE_FORMAT_END);
}
private static String getLegacyEasingContent(String str, String str2) {
return str.substring(str2.length() + 1, str.length() - 1);
}
private static float getLegacyControlPoint(String[] strArr, int i) {
float parseFloat = Float.parseFloat(strArr[i]);
if (parseFloat >= 0.0f && parseFloat <= 1.0f) {
return parseFloat;
}
throw new IllegalArgumentException("Motion easing control point value must be between 0 and 1; instead got: " + parseFloat);
}
}