package androidx.appcompat.widget;

import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.widget.CheckedTextView;

/* JADX INFO: compiled from: AppCompatCheckedTextViewHelper.java */
/* JADX INFO: loaded from: classes.dex */
class i {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    private final CheckedTextView f934a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    private ColorStateList f935b = null;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    private PorterDuff.Mode f936c = null;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    private boolean f937d = false;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    private boolean f938e = false;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    private boolean f939f;

    i(CheckedTextView checkedTextView) {
        this.f934a = checkedTextView;
    }

    void a() {
        Drawable drawableA = androidx.core.widget.c.a(this.f934a);
        if (drawableA != null) {
            if (this.f937d || this.f938e) {
                Drawable drawableMutate = androidx.core.graphics.drawable.a.r(drawableA).mutate();
                if (this.f937d) {
                    androidx.core.graphics.drawable.a.o(drawableMutate, this.f935b);
                }
                if (this.f938e) {
                    androidx.core.graphics.drawable.a.p(drawableMutate, this.f936c);
                }
                if (drawableMutate.isStateful()) {
                    drawableMutate.setState(this.f934a.getDrawableState());
                }
                this.f934a.setCheckMarkDrawable(drawableMutate);
            }
        }
    }

    ColorStateList b() {
        return this.f935b;
    }

    PorterDuff.Mode c() {
        return this.f936c;
    }

    void d(AttributeSet attributeSet, int i3) {
        boolean z2;
        int iN;
        int iN2;
        Context context = this.f934a.getContext();
        int[] iArr = c.j.M0;
        a1 a1VarV = a1.v(context, attributeSet, iArr, i3, 0);
        CheckedTextView checkedTextView = this.f934a;
        androidx.core.view.y.p0(checkedTextView, checkedTextView.getContext(), iArr, attributeSet, a1VarV.r(), i3, 0);
        try {
            int i4 = c.j.O0;
            if (!a1VarV.s(i4) || (iN2 = a1VarV.n(i4, 0)) == 0) {
                z2 = false;
            } else {
                try {
                    CheckedTextView checkedTextView2 = this.f934a;
                    checkedTextView2.setCheckMarkDrawable(d.a.b(checkedTextView2.getContext(), iN2));
                    z2 = true;
                } catch (Resources.NotFoundException unused) {
                    z2 = false;
                }
            }
            if (!z2) {
                int i5 = c.j.N0;
                if (a1VarV.s(i5) && (iN = a1VarV.n(i5, 0)) != 0) {
                    CheckedTextView checkedTextView3 = this.f934a;
                    checkedTextView3.setCheckMarkDrawable(d.a.b(checkedTextView3.getContext(), iN));
                }
            }
            int i6 = c.j.P0;
            if (a1VarV.s(i6)) {
                androidx.core.widget.c.b(this.f934a, a1VarV.c(i6));
            }
            int i7 = c.j.Q0;
            if (a1VarV.s(i7)) {
                androidx.core.widget.c.c(this.f934a, i0.d(a1VarV.k(i7, -1), null));
            }
        } finally {
            a1VarV.w();
        }
    }

    void e() {
        if (this.f939f) {
            this.f939f = false;
        } else {
            this.f939f = true;
            a();
        }
    }

    void f(ColorStateList colorStateList) {
        this.f935b = colorStateList;
        this.f937d = true;
        a();
    }

    void g(PorterDuff.Mode mode) {
        this.f936c = mode;
        this.f938e = true;
        a();
    }
}
