package o;

import android.animation.AnimatorSet;
import android.animation.TimeInterpolator;
import android.animation.ValueAnimator;
import android.view.View;
import android.widget.EditText;
import com.google.android.gms.common.R;
import com.google.android.material.internal.CheckableImageButton;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* renamed from: o.ai, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public final class C0738ai extends AbstractC1052dw {
    public final int e;
    public final int f;
    public final TimeInterpolator g;
    public final TimeInterpolator h;
    public EditText i;
    public final ViewOnClickListenerC0604Xh j;
    public final ViewOnFocusChangeListenerC0417Qc k;
    public AnimatorSet l;
    public ValueAnimator m;

    public C0738ai(C0957cw c0957cw) {
        super(c0957cw);
        this.j = new ViewOnClickListenerC0604Xh(0, this);
        this.k = new ViewOnFocusChangeListenerC0417Qc(1, this);
        this.e = AbstractC0752ap.a0(c0957cw.getContext(), R.attr.motionDurationShort3, 100);
        this.f = AbstractC0752ap.a0(c0957cw.getContext(), R.attr.motionDurationShort3, 150);
        this.g = AbstractC0752ap.b0(c0957cw.getContext(), R.attr.motionEasingLinearInterpolator, T6.a);
        this.h = AbstractC0752ap.b0(c0957cw.getContext(), R.attr.motionEasingEmphasizedInterpolator, T6.d);
    }

    @Override // o.AbstractC1052dw
    public final void a() {
        if (this.b.A != null) {
            return;
        }
        s(t());
    }

    @Override // o.AbstractC1052dw
    public final int c() {
        return R.string.clear_text_end_icon_content_description;
    }

    @Override // o.AbstractC1052dw
    public final int d() {
        return R.drawable.mtrl_ic_cancel;
    }

    @Override // o.AbstractC1052dw
    public final View.OnFocusChangeListener e() {
        return this.k;
    }

    @Override // o.AbstractC1052dw
    public final View.OnClickListener f() {
        return this.j;
    }

    @Override // o.AbstractC1052dw
    public final View.OnFocusChangeListener g() {
        return this.k;
    }

    @Override // o.AbstractC1052dw
    public final void l(EditText editText) {
        this.i = editText;
        this.a.setEndIconVisible(t());
    }

    @Override // o.AbstractC1052dw
    public final void o(boolean z) {
        if (this.b.A == null) {
            return;
        }
        s(z);
    }

    @Override // o.AbstractC1052dw
    public final void q() {
        ValueAnimator valueAnimatorOfFloat = ValueAnimator.ofFloat(0.8f, 1.0f);
        valueAnimatorOfFloat.setInterpolator(this.h);
        valueAnimatorOfFloat.setDuration(this.f);
        final int i = 1;
        valueAnimatorOfFloat.addUpdateListener(new ValueAnimator.AnimatorUpdateListener(this) { // from class: o.Yh
            public final /* synthetic */ C0738ai b;

            {
                this.b = this;
            }

            @Override // android.animation.ValueAnimator.AnimatorUpdateListener
            public final void onAnimationUpdate(ValueAnimator valueAnimator) {
                switch (i) {
                    case 0:
                        C0738ai c0738ai = this.b;
                        c0738ai.getClass();
                        c0738ai.d.setAlpha(((Float) valueAnimator.getAnimatedValue()).floatValue());
                        break;
                    default:
                        C0738ai c0738ai2 = this.b;
                        c0738ai2.getClass();
                        float fFloatValue = ((Float) valueAnimator.getAnimatedValue()).floatValue();
                        CheckableImageButton checkableImageButton = c0738ai2.d;
                        checkableImageButton.setScaleX(fFloatValue);
                        checkableImageButton.setScaleY(fFloatValue);
                        break;
                }
            }
        });
        ValueAnimator valueAnimatorOfFloat2 = ValueAnimator.ofFloat(0.0f, 1.0f);
        TimeInterpolator timeInterpolator = this.g;
        valueAnimatorOfFloat2.setInterpolator(timeInterpolator);
        int i2 = this.e;
        valueAnimatorOfFloat2.setDuration(i2);
        final int i3 = 0;
        valueAnimatorOfFloat2.addUpdateListener(new ValueAnimator.AnimatorUpdateListener(this) { // from class: o.Yh
            public final /* synthetic */ C0738ai b;

            {
                this.b = this;
            }

            @Override // android.animation.ValueAnimator.AnimatorUpdateListener
            public final void onAnimationUpdate(ValueAnimator valueAnimator) {
                switch (i3) {
                    case 0:
                        C0738ai c0738ai = this.b;
                        c0738ai.getClass();
                        c0738ai.d.setAlpha(((Float) valueAnimator.getAnimatedValue()).floatValue());
                        break;
                    default:
                        C0738ai c0738ai2 = this.b;
                        c0738ai2.getClass();
                        float fFloatValue = ((Float) valueAnimator.getAnimatedValue()).floatValue();
                        CheckableImageButton checkableImageButton = c0738ai2.d;
                        checkableImageButton.setScaleX(fFloatValue);
                        checkableImageButton.setScaleY(fFloatValue);
                        break;
                }
            }
        });
        AnimatorSet animatorSet = new AnimatorSet();
        this.l = animatorSet;
        animatorSet.playTogether(valueAnimatorOfFloat, valueAnimatorOfFloat2);
        this.l.addListener(new C0656Zh(this, i3));
        ValueAnimator valueAnimatorOfFloat3 = ValueAnimator.ofFloat(1.0f, 0.0f);
        valueAnimatorOfFloat3.setInterpolator(timeInterpolator);
        valueAnimatorOfFloat3.setDuration(i2);
        valueAnimatorOfFloat3.addUpdateListener(new ValueAnimator.AnimatorUpdateListener(this) { // from class: o.Yh
            public final /* synthetic */ C0738ai b;

            {
                this.b = this;
            }

            @Override // android.animation.ValueAnimator.AnimatorUpdateListener
            public final void onAnimationUpdate(ValueAnimator valueAnimator) {
                switch (i3) {
                    case 0:
                        C0738ai c0738ai = this.b;
                        c0738ai.getClass();
                        c0738ai.d.setAlpha(((Float) valueAnimator.getAnimatedValue()).floatValue());
                        break;
                    default:
                        C0738ai c0738ai2 = this.b;
                        c0738ai2.getClass();
                        float fFloatValue = ((Float) valueAnimator.getAnimatedValue()).floatValue();
                        CheckableImageButton checkableImageButton = c0738ai2.d;
                        checkableImageButton.setScaleX(fFloatValue);
                        checkableImageButton.setScaleY(fFloatValue);
                        break;
                }
            }
        });
        this.m = valueAnimatorOfFloat3;
        valueAnimatorOfFloat3.addListener(new C0656Zh(this, i));
    }

    @Override // o.AbstractC1052dw
    public final void r() {
        EditText editText = this.i;
        if (editText != null) {
            editText.post(new RunnableC2108p1(5, this));
        }
    }

    public final void s(boolean z) {
        boolean z2 = this.b.d() == z;
        if (z && !this.l.isRunning()) {
            this.m.cancel();
            this.l.start();
            if (z2) {
                this.l.end();
                return;
            }
            return;
        }
        if (z) {
            return;
        }
        this.l.cancel();
        this.m.start();
        if (z2) {
            this.m.end();
        }
    }

    public final boolean t() {
        EditText editText = this.i;
        if (editText != null) {
            return (editText.hasFocus() || this.d.hasFocus()) && this.i.getText().length() > 0;
        }
        return false;
    }
}
