package d.b.g;

import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.View;
import d.h.j.y;
import java.util.concurrent.atomic.AtomicInteger;

/* JADX INFO: loaded from: classes.dex */
public class e {
    public final View a;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public x0 f1950d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public x0 f1951e;

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

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public int f1949c = -1;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final j f1948b = j.a();

    public e(View view) {
        this.a = view;
    }

    public void a() {
        Drawable background = this.a.getBackground();
        if (background != null) {
            boolean z2 = true;
            if (this.f1950d != null) {
                if (this.f1952f == null) {
                    this.f1952f = new x0();
                }
                x0 x0Var = this.f1952f;
                x0Var.a = null;
                x0Var.f2121d = false;
                x0Var.f2119b = null;
                x0Var.f2120c = false;
                View view = this.a;
                AtomicInteger atomicInteger = d.h.j.y.a;
                ColorStateList colorStateListG = y.h.g(view);
                if (colorStateListG != null) {
                    x0Var.f2121d = true;
                    x0Var.a = colorStateListG;
                }
                PorterDuff.Mode modeH = y.h.h(this.a);
                if (modeH != null) {
                    x0Var.f2120c = true;
                    x0Var.f2119b = modeH;
                }
                if (x0Var.f2121d || x0Var.f2120c) {
                    j.f(background, x0Var, this.a.getDrawableState());
                } else {
                    z2 = false;
                }
                if (z2) {
                    return;
                }
            }
            x0 x0Var2 = this.f1951e;
            if (x0Var2 != null) {
                j.f(background, x0Var2, this.a.getDrawableState());
                return;
            }
            x0 x0Var3 = this.f1950d;
            if (x0Var3 != null) {
                j.f(background, x0Var3, this.a.getDrawableState());
            }
        }
    }

    public ColorStateList b() {
        x0 x0Var = this.f1951e;
        if (x0Var != null) {
            return x0Var.a;
        }
        return null;
    }

    public PorterDuff.Mode c() {
        x0 x0Var = this.f1951e;
        if (x0Var != null) {
            return x0Var.f2119b;
        }
        return null;
    }

    public void d(AttributeSet attributeSet, int i2) {
        Context context = this.a.getContext();
        int[] iArr = d.b.b.f1552y;
        z0 z0VarQ = z0.q(context, attributeSet, iArr, i2, 0);
        View view = this.a;
        d.h.j.y.o(view, view.getContext(), iArr, attributeSet, z0VarQ.f2138b, i2, 0);
        try {
            if (z0VarQ.o(0)) {
                this.f1949c = z0VarQ.l(0, -1);
                ColorStateList colorStateListD = this.f1948b.d(this.a.getContext(), this.f1949c);
                if (colorStateListD != null) {
                    g(colorStateListD);
                }
            }
            if (z0VarQ.o(1)) {
                y.h.q(this.a, z0VarQ.c(1));
            }
            if (z0VarQ.o(2)) {
                y.h.r(this.a, g0.b(z0VarQ.j(2, -1), null));
            }
            z0VarQ.f2138b.recycle();
        } catch (Throwable th) {
            z0VarQ.f2138b.recycle();
            throw th;
        }
    }

    public void e() {
        this.f1949c = -1;
        g(null);
        a();
    }

    public void f(int i2) {
        this.f1949c = i2;
        j jVar = this.f1948b;
        g(jVar != null ? jVar.d(this.a.getContext(), i2) : null);
        a();
    }

    public void g(ColorStateList colorStateList) {
        if (colorStateList != null) {
            if (this.f1950d == null) {
                this.f1950d = new x0();
            }
            x0 x0Var = this.f1950d;
            x0Var.a = colorStateList;
            x0Var.f2121d = true;
        } else {
            this.f1950d = null;
        }
        a();
    }

    public void h(ColorStateList colorStateList) {
        if (this.f1951e == null) {
            this.f1951e = new x0();
        }
        x0 x0Var = this.f1951e;
        x0Var.a = colorStateList;
        x0Var.f2121d = true;
        a();
    }

    public void i(PorterDuff.Mode mode) {
        if (this.f1951e == null) {
            this.f1951e = new x0();
        }
        x0 x0Var = this.f1951e;
        x0Var.f2119b = mode;
        x0Var.f2120c = true;
        a();
    }
}
