alexandroid/decompiled/jadx/sources/com/google/android/material/motion/MaterialBottomContainerBackHelper.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

122 lines
5.5 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.content.res.Resources;
import android.util.Property;
import android.view.View;
import android.view.ViewGroup;
import androidx.activity.BackEventCompat;
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 MaterialBottomContainerBackHelper extends MaterialBackAnimationHelper<View> {
private final float maxScaleXDistance;
private final float maxScaleYDistance;
public MaterialBottomContainerBackHelper(@NonNull 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);
}
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));
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.setInterpolator(new FastOutSlowInInterpolator());
return animatorSet;
}
public void cancelBackProgress() {
if (super.onCancelBackProgress() == null) {
return;
}
Animator createResetScaleAnimator = createResetScaleAnimator();
createResetScaleAnimator.setDuration(this.cancelDuration);
createResetScaleAnimator.start();
}
public void finishBackProgressNotPersistent(@NonNull BackEventCompat backEventCompat, @Nullable Animator.AnimatorListener animatorListener) {
ObjectAnimator ofFloat = ObjectAnimator.ofFloat(this.view, (Property<V, Float>) View.TRANSLATION_Y, this.view.getScaleY() * this.view.getHeight());
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 finishBackProgressPersistent(@NonNull BackEventCompat backEventCompat, @Nullable 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 startBackProgress(@NonNull BackEventCompat backEventCompat) {
super.onStartBackProgress(backEventCompat);
}
@VisibleForTesting
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);
if (Float.isNaN(lerp) || Float.isNaN(lerp2)) {
return;
}
this.view.setScaleX(lerp);
this.view.setPivotY(height);
this.view.setScaleY(lerp2);
V v = this.view;
if (v instanceof ViewGroup) {
ViewGroup viewGroup = (ViewGroup) v;
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 updateBackProgress(@NonNull BackEventCompat backEventCompat) {
if (super.onUpdateBackProgress(backEventCompat) == null) {
return;
}
updateBackProgress(backEventCompat.getProgress());
}
}