package com.google.android.material.motion;

import android.animation.TimeInterpolator;
import android.content.Context;
import android.util.Log;
import android.view.View;
import android.view.animation.PathInterpolator;
import com.google.android.material.R;
import defpackage.m38;
import defpackage.rq6;
import defpackage.t50;
import defpackage.vo6;

/* JADX INFO: loaded from: classes2.dex */
@m38
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";

    @rq6
    private t50 backEvent;
    protected final int cancelDuration;
    protected final int hideDurationMax;
    protected final int hideDurationMin;

    @vo6
    private final TimeInterpolator progressInterpolator;

    @vo6
    protected final V view;

    public MaterialBackAnimationHelper(@vo6 V v) {
        this.view = v;
        Context context = v.getContext();
        this.progressInterpolator = MotionUtils.resolveThemeInterpolator(context, R.attr.motionEasingStandardDecelerateInterpolator, new PathInterpolator(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);
    }

    public float interpolateProgress(float f) {
        return this.progressInterpolator.getInterpolation(f);
    }

    @rq6
    public t50 onCancelBackProgress() {
        if (this.backEvent == null) {
            Log.w(TAG, "Must call startBackProgress() and updateBackProgress() before cancelBackProgress()");
        }
        t50 t50Var = this.backEvent;
        this.backEvent = null;
        return t50Var;
    }

    @rq6
    public t50 onHandleBackInvoked() {
        t50 t50Var = this.backEvent;
        this.backEvent = null;
        return t50Var;
    }

    public void onStartBackProgress(@vo6 t50 t50Var) {
        this.backEvent = t50Var;
    }

    @rq6
    public t50 onUpdateBackProgress(@vo6 t50 t50Var) {
        if (this.backEvent == null) {
            Log.w(TAG, "Must call startBackProgress() before updateBackProgress()");
        }
        t50 t50Var2 = this.backEvent;
        this.backEvent = t50Var;
        return t50Var2;
    }
}
