package d.b.g;

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: loaded from: classes.dex */
public class i {
    public final CompoundButton a;

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

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

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

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

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

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

    public void a() {
        Drawable drawableA = d.h.k.d.a(this.a);
        if (drawableA != null) {
            if (this.f1978d || this.f1979e) {
                Drawable drawableMutate = drawableA.mutate();
                if (this.f1978d) {
                    d.h.d.k.b.h(drawableMutate, this.f1976b);
                }
                if (this.f1979e) {
                    d.h.d.k.b.i(drawableMutate, this.f1977c);
                }
                if (drawableMutate.isStateful()) {
                    drawableMutate.setState(this.a.getDrawableState());
                }
                this.a.setButtonDrawable(drawableMutate);
            }
        }
    }

    public void b(AttributeSet attributeSet, int i2) {
        int iL;
        int iL2;
        Context context = this.a.getContext();
        int[] iArr = d.b.b.f1539l;
        z0 z0VarQ = z0.q(context, attributeSet, iArr, i2, 0);
        CompoundButton compoundButton = this.a;
        d.h.j.y.o(compoundButton, compoundButton.getContext(), iArr, attributeSet, z0VarQ.f2138b, i2, 0);
        boolean z2 = true;
        try {
            if (!z0VarQ.o(1) || (iL2 = z0VarQ.l(1, 0)) == 0) {
                z2 = false;
            } else {
                try {
                    CompoundButton compoundButton2 = this.a;
                    compoundButton2.setButtonDrawable(d.b.d.a.a.a(compoundButton2.getContext(), iL2));
                } catch (Resources.NotFoundException unused) {
                    z2 = false;
                }
            }
            if (!z2 && z0VarQ.o(0) && (iL = z0VarQ.l(0, 0)) != 0) {
                CompoundButton compoundButton3 = this.a;
                compoundButton3.setButtonDrawable(d.b.d.a.a.a(compoundButton3.getContext(), iL));
            }
            if (z0VarQ.o(2)) {
                d.h.k.c.c(this.a, z0VarQ.c(2));
            }
            if (z0VarQ.o(3)) {
                d.h.k.c.d(this.a, g0.b(z0VarQ.j(3, -1), null));
            }
            z0VarQ.f2138b.recycle();
        } catch (Throwable th) {
            z0VarQ.f2138b.recycle();
            throw th;
        }
    }
}
