package n9;

import android.animation.Animator;
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.annotation.NonNull;
import androidx.annotation.Nullable;

/* JADX INFO: loaded from: classes2.dex */
public final class h extends a {

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public final float f31117f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public final float f31118g;

    public h(View view) {
        super(view);
        Resources resources = view.getResources();
        this.f31117f = resources.getDimension(x8.e.m3_back_progress_bottom_container_max_scale_x_distance);
        this.f31118g = resources.getDimension(x8.e.m3_back_progress_bottom_container_max_scale_y_distance);
    }

    public final void b() {
        if (super.onCancelBackProgress() == null) {
            return;
        }
        AnimatorSet animatorSetC = c();
        animatorSetC.setDuration(this.f31112e);
        animatorSetC.start();
    }

    public final AnimatorSet c() {
        AnimatorSet animatorSet = new AnimatorSet();
        View view = this.f31109b;
        animatorSet.playTogether(ObjectAnimator.ofFloat(view, (Property<View, Float>) View.SCALE_X, 1.0f), ObjectAnimator.ofFloat(view, (Property<View, Float>) View.SCALE_Y, 1.0f));
        if (view instanceof ViewGroup) {
            ViewGroup viewGroup = (ViewGroup) view;
            for (int i10 = 0; i10 < viewGroup.getChildCount(); i10++) {
                animatorSet.playTogether(ObjectAnimator.ofFloat(viewGroup.getChildAt(i10), (Property<View, Float>) View.SCALE_Y, 1.0f));
            }
        }
        animatorSet.setInterpolator(new l1.b());
        return animatorSet;
    }

    public final void d(float f10) {
        float interpolation = this.f31108a.getInterpolation(f10);
        View view = this.f31109b;
        float width = view.getWidth();
        float height = view.getHeight();
        if (width <= 0.0f || height <= 0.0f) {
            return;
        }
        float f11 = this.f31117f / width;
        float f12 = this.f31118g / height;
        float fA = 1.0f - y8.a.a(0.0f, f11, interpolation);
        float fA2 = 1.0f - y8.a.a(0.0f, f12, interpolation);
        if (Float.isNaN(fA) || Float.isNaN(fA2)) {
            return;
        }
        view.setScaleX(fA);
        view.setPivotY(height);
        view.setScaleY(fA2);
        if (view instanceof ViewGroup) {
            ViewGroup viewGroup = (ViewGroup) view;
            for (int i10 = 0; i10 < viewGroup.getChildCount(); i10++) {
                View childAt = viewGroup.getChildAt(i10);
                childAt.setPivotY(-childAt.getTop());
                childAt.setScaleY(fA2 != 0.0f ? fA / fA2 : 1.0f);
            }
        }
    }

    public final void e(androidx.activity.b bVar) {
        if (super.onUpdateBackProgress(bVar) == null) {
            return;
        }
        d(bVar.f468c);
    }

    public void finishBackProgressNotPersistent(@NonNull androidx.activity.b bVar, @Nullable Animator.AnimatorListener animatorListener) {
        View view = this.f31109b;
        ObjectAnimator objectAnimatorOfFloat = ObjectAnimator.ofFloat(view, (Property<View, Float>) View.TRANSLATION_Y, view.getScaleY() * view.getHeight());
        objectAnimatorOfFloat.setInterpolator(new l1.b());
        objectAnimatorOfFloat.setDuration(y8.a.c(bVar.f468c, this.f31110c, this.f31111d));
        objectAnimatorOfFloat.addListener(new l.e(this, 8));
        if (animatorListener != null) {
            objectAnimatorOfFloat.addListener(animatorListener);
        }
        objectAnimatorOfFloat.start();
    }

    public void finishBackProgressPersistent(@NonNull androidx.activity.b bVar, @Nullable Animator.AnimatorListener animatorListener) {
        AnimatorSet animatorSetC = c();
        animatorSetC.setDuration(y8.a.c(bVar.f468c, this.f31110c, this.f31111d));
        if (animatorListener != null) {
            animatorSetC.addListener(animatorListener);
        }
        animatorSetC.start();
    }
}
