package com.google.android.material.behavior;

import X.05p;
import X.1gt;
import X.Okd;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.TimeInterpolator;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewPropertyAnimator;
import com.bytedance.covode.number.Covode;

public class HideBottomViewOnScrollBehavior<V extends View> extends 05p<V> {
    public ViewPropertyAnimator LIZ;
    public int LIZIZ;
    public int LIZJ = 2;

    static {
        Covode.recordClassIndex(43887);
    }

    public boolean onStartNestedScroll(1gt r2, V v, View view, View view2, int i) {
        return i == 2;
    }

    public HideBottomViewOnScrollBehavior() {
    }

    public void LIZIZ(V v) {
        ViewPropertyAnimator viewPropertyAnimator = this.LIZ;
        V v2 = v;
        if (viewPropertyAnimator != null) {
            viewPropertyAnimator.cancel();
            v2.clearAnimation();
        }
        this.LIZJ = 1;
        LIZ(v2, this.LIZIZ, 175, Okd.LIZJ);
    }

    public void LIZ(V v) {
        ViewPropertyAnimator viewPropertyAnimator = this.LIZ;
        V v2 = v;
        if (viewPropertyAnimator != null) {
            viewPropertyAnimator.cancel();
            v2.clearAnimation();
        }
        this.LIZJ = 2;
        LIZ(v2, 0, 225, Okd.LIZLLL);
    }

    public HideBottomViewOnScrollBehavior(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
    }

    public boolean onLayoutChild(1gt r2, V v, int i) {
        this.LIZIZ = v.getMeasuredHeight();
        return HideBottomViewOnScrollBehavior.super.onLayoutChild(r2, v, i);
    }

    private void LIZ(V v, int i, long j, TimeInterpolator timeInterpolator) {
        this.LIZ = v.animate().translationY((float) i).setInterpolator(timeInterpolator).setDuration(j).setListener(new AnimatorListenerAdapter() {
            static {
                Covode.recordClassIndex(43888);
            }

            public final void onAnimationEnd(Animator animator) {
                HideBottomViewOnScrollBehavior.this.LIZ = null;
            }
        });
    }

    public void onNestedScroll(1gt r3, V v, View view, int i, int i2, int i3, int i4) {
        int i5 = this.LIZJ;
        if (i5 != 1) {
            if (i2 > 0) {
                LIZIZ(v);
                return;
            } else if (i5 == 2) {
                return;
            }
        }
        if (i2 < 0) {
            LIZ(v);
        }
    }
}
