package l;

import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.widget.CompoundButton;
import androidx.annotation.Nullable;

/* JADX INFO: loaded from: classes.dex */
public final class a0 {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final CompoundButton f29598a;

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

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

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

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

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

    public a0(CompoundButton compoundButton) {
        this.f29598a = compoundButton;
    }

    public final void a() {
        CompoundButton compoundButton = this.f29598a;
        Drawable buttonDrawable = u0.d.getButtonDrawable(compoundButton);
        if (buttonDrawable != null) {
            if (this.f29601d || this.f29602e) {
                Drawable drawableMutate = buttonDrawable.mutate();
                if (this.f29601d) {
                    k0.a.setTintList(drawableMutate, this.f29599b);
                }
                if (this.f29602e) {
                    k0.a.setTintMode(drawableMutate, this.f29600c);
                }
                if (drawableMutate.isStateful()) {
                    drawableMutate.setState(compoundButton.getDrawableState());
                }
                compoundButton.setButtonDrawable(drawableMutate);
            }
        }
    }

    public void loadFromAttributes(@Nullable AttributeSet attributeSet, int i10) {
        int i11;
        int resourceId;
        int resourceId2;
        CompoundButton compoundButton = this.f29598a;
        Context context = compoundButton.getContext();
        int[] iArr = d.j.CompoundButton;
        p3 p3VarD = p3.d(context, attributeSet, iArr, i10);
        TypedArray typedArray = p3VarD.f29809b;
        androidx.core.view.s1.saveAttributeDataForStyleable(compoundButton, compoundButton.getContext(), iArr, attributeSet, p3VarD.f29809b, i10, 0);
        try {
            int i12 = d.j.CompoundButton_buttonCompat;
            if (!typedArray.hasValue(i12) || (resourceId2 = typedArray.getResourceId(i12, 0)) == 0) {
                i11 = d.j.CompoundButton_android_button;
                if (typedArray.hasValue(i11) && (resourceId = typedArray.getResourceId(i11, 0)) != 0) {
                    compoundButton.setButtonDrawable(f.a.getDrawable(compoundButton.getContext(), resourceId));
                }
            } else {
                try {
                    compoundButton.setButtonDrawable(f.a.getDrawable(compoundButton.getContext(), resourceId2));
                } catch (Resources.NotFoundException unused) {
                    i11 = d.j.CompoundButton_android_button;
                    if (typedArray.hasValue(i11)) {
                        compoundButton.setButtonDrawable(f.a.getDrawable(compoundButton.getContext(), resourceId));
                    }
                }
            }
            int i13 = d.j.CompoundButton_buttonTint;
            if (typedArray.hasValue(i13)) {
                u0.d.setButtonTintList(compoundButton, p3VarD.a(i13));
            }
            int i14 = d.j.CompoundButton_buttonTintMode;
            if (typedArray.hasValue(i14)) {
                u0.d.setButtonTintMode(compoundButton, p1.c(typedArray.getInt(i14, -1), null));
            }
        } finally {
            p3VarD.e();
        }
    }

    public void setSupportButtonTintMode(@Nullable PorterDuff.Mode mode) {
        this.f29600c = mode;
        this.f29602e = true;
        a();
    }
}
