alexandroid/decompiled/jadx/sources/com/google/android/material/motion/MaterialSideContainerBackHelper.java
KaKi87 a47fad5135 📦 Add decompiled Alexa 2.2.730155.0 (jadx, apktool, Hermes strings)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-07 00:04:16 +01:00

157 lines
7.1 KiB
Java

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.Gravity;
import android.view.View;
import android.view.ViewGroup;
import androidx.activity.BackEventCompat;
import androidx.annotation.GravityInt;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.VisibleForTesting;
import androidx.interpolator.view.animation.FastOutSlowInInterpolator;
import com.google.android.material.R;
import com.google.android.material.animation.AnimationUtils;
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
/* loaded from: classes7.dex */
public class MaterialSideContainerBackHelper extends MaterialBackAnimationHelper<View> {
private final float maxScaleXDistanceGrow;
private final float maxScaleXDistanceShrink;
private final float maxScaleYDistance;
public MaterialSideContainerBackHelper(@NonNull 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);
}
private boolean checkAbsoluteGravity(@GravityInt int i, @GravityInt int i2) {
return (Gravity.getAbsoluteGravity(i, this.view.getLayoutDirection()) & 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;
}
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));
V v = this.view;
if (v instanceof ViewGroup) {
ViewGroup viewGroup = (ViewGroup) v;
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();
}
public void finishBackProgress(@NonNull BackEventCompat backEventCompat, @GravityInt final int i, @Nullable Animator.AnimatorListener animatorListener, @Nullable ValueAnimator.AnimatorUpdateListener animatorUpdateListener) {
final boolean z = backEventCompat.getSwipeEdge() == 0;
boolean checkAbsoluteGravity = checkAbsoluteGravity(i, 3);
float scaleX = (this.view.getScaleX() * this.view.getWidth()) + getEdgeMargin(checkAbsoluteGravity);
V v = this.view;
Property property = View.TRANSLATION_X;
if (checkAbsoluteGravity) {
scaleX = -scaleX;
}
ObjectAnimator ofFloat = ObjectAnimator.ofFloat(v, (Property<V, Float>) property, scaleX);
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 startBackProgress(@NonNull BackEventCompat backEventCompat) {
super.onStartBackProgress(backEventCompat);
}
@VisibleForTesting
public void updateBackProgress(float f, boolean z, @GravityInt int i) {
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;
float lerp2 = 1.0f - AnimationUtils.lerp(0.0f, f6, interpolateProgress);
if (Float.isNaN(f7) || Float.isNaN(lerp2)) {
return;
}
this.view.setScaleX(f7);
this.view.setScaleY(lerp2);
V v2 = this.view;
if (v2 instanceof ViewGroup) {
ViewGroup viewGroup = (ViewGroup) v2;
for (int i2 = 0; i2 < viewGroup.getChildCount(); i2++) {
View childAt = viewGroup.getChildAt(i2);
childAt.setPivotX(checkAbsoluteGravity ? childAt.getWidth() + (width - childAt.getRight()) : -childAt.getLeft());
childAt.setPivotY(-childAt.getTop());
float f8 = z2 ? 1.0f - lerp : 1.0f;
float f9 = lerp2 != 0.0f ? (f7 / lerp2) * f8 : 1.0f;
if (!Float.isNaN(f8) && !Float.isNaN(f9)) {
childAt.setScaleX(f8);
childAt.setScaleY(f9);
}
}
}
}
}
public void updateBackProgress(@NonNull BackEventCompat backEventCompat, @GravityInt int i) {
if (super.onUpdateBackProgress(backEventCompat) == null) {
return;
}
updateBackProgress(backEventCompat.getProgress(), backEventCompat.getSwipeEdge() == 0, i);
}
}