package c.b.f;

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.CompoundButton;

/* JADX INFO: compiled from: AppCompatCompoundButtonHelper.java */
/* JADX INFO: loaded from: classes.dex */
public class l {
    public final CompoundButton a;

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

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

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

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

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

    public l(CompoundButton compoundButton) {
        this.a = compoundButton;
    }

    public void a() {
        Drawable drawableA = c.f.k.c.a(this.a);
        if (drawableA != null) {
            if (this.f877d || this.f878e) {
                Drawable drawableMutate = drawableA.mutate();
                if (this.f877d) {
                    c.f.d.l.b.h(drawableMutate, this.f875b);
                }
                if (this.f878e) {
                    c.f.d.l.b.i(drawableMutate, this.f876c);
                }
                if (drawableMutate.isStateful()) {
                    drawableMutate.setState(this.a.getDrawableState());
                }
                this.a.setButtonDrawable(drawableMutate);
            }
        }
    }

    public void b(AttributeSet attributeSet, int i2) {
        int iJ;
        int iJ2;
        Context context = this.a.getContext();
        int[] iArr = c.b.b.m;
        d1 d1VarO = d1.o(context, attributeSet, iArr, i2, 0);
        CompoundButton compoundButton = this.a;
        c.f.j.a0.k(compoundButton, compoundButton.getContext(), iArr, attributeSet, d1VarO.f806b, i2, 0);
        boolean z = true;
        try {
            if (!d1VarO.m(1) || (iJ2 = d1VarO.j(1, 0)) == 0) {
                z = false;
            } else {
                try {
                    CompoundButton compoundButton2 = this.a;
                    compoundButton2.setButtonDrawable(c.b.a.e(compoundButton2.getContext(), iJ2));
                } catch (Resources.NotFoundException unused) {
                    z = false;
                }
            }
            if (!z && d1VarO.m(0) && (iJ = d1VarO.j(0, 0)) != 0) {
                CompoundButton compoundButton3 = this.a;
                compoundButton3.setButtonDrawable(c.b.a.e(compoundButton3.getContext(), iJ));
            }
            if (d1VarO.m(2)) {
                c.f.k.b.c(this.a, d1VarO.b(2));
            }
            if (d1VarO.m(3)) {
                c.f.k.b.d(this.a, k0.c(d1VarO.h(3, -1), null));
            }
            d1VarO.f806b.recycle();
        } catch (Throwable th) {
            d1VarO.f806b.recycle();
            throw th;
        }
    }
}
