package c.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 java.util.WeakHashMap;

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

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

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

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

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

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

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

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

    public void a() {
        Drawable background = this.f4928a.getBackground();
        if (background != null) {
            boolean z = true;
            if (this.f4931d != null) {
                if (this.f4933f == null) {
                    this.f4933f = new j0();
                }
                j0 j0Var = this.f4933f;
                j0Var.f4980a = null;
                j0Var.f4983d = false;
                j0Var.f4981b = null;
                j0Var.f4982c = false;
                View view = this.f4928a;
                WeakHashMap<View, c.e.i.q> weakHashMap = c.e.i.l.f5278a;
                ColorStateList backgroundTintList = view.getBackgroundTintList();
                if (backgroundTintList != null) {
                    j0Var.f4983d = true;
                    j0Var.f4980a = backgroundTintList;
                }
                PorterDuff.Mode backgroundTintMode = this.f4928a.getBackgroundTintMode();
                if (backgroundTintMode != null) {
                    j0Var.f4982c = true;
                    j0Var.f4981b = backgroundTintMode;
                }
                if (j0Var.f4983d || j0Var.f4982c) {
                    f.e(background, j0Var, this.f4928a.getDrawableState());
                } else {
                    z = false;
                }
                if (z) {
                    return;
                }
            }
            j0 j0Var2 = this.f4932e;
            if (j0Var2 != null) {
                f.e(background, j0Var2, this.f4928a.getDrawableState());
                return;
            }
            j0 j0Var3 = this.f4931d;
            if (j0Var3 != null) {
                f.e(background, j0Var3, this.f4928a.getDrawableState());
            }
        }
    }

    public ColorStateList b() {
        j0 j0Var = this.f4932e;
        if (j0Var != null) {
            return j0Var.f4980a;
        }
        return null;
    }

    public PorterDuff.Mode c() {
        j0 j0Var = this.f4932e;
        if (j0Var != null) {
            return j0Var.f4981b;
        }
        return null;
    }

    public void d(AttributeSet attributeSet, int i2) {
        Context context = this.f4928a.getContext();
        int[] iArr = c.b.b.y;
        l0 l0VarN = l0.n(context, attributeSet, iArr, i2, 0);
        View view = this.f4928a;
        c.e.i.l.f(view, view.getContext(), iArr, attributeSet, l0VarN.f4986b, i2, 0);
        try {
            if (l0VarN.l(0)) {
                this.f4930c = l0VarN.i(0, -1);
                ColorStateList colorStateListC = this.f4929b.c(this.f4928a.getContext(), this.f4930c);
                if (colorStateListC != null) {
                    g(colorStateListC);
                }
            }
            if (l0VarN.l(1)) {
                this.f4928a.setBackgroundTintList(l0VarN.b(1));
            }
            if (l0VarN.l(2)) {
                this.f4928a.setBackgroundTintMode(t.b(l0VarN.g(2, -1), null));
            }
            l0VarN.f4986b.recycle();
        } catch (Throwable th) {
            l0VarN.f4986b.recycle();
            throw th;
        }
    }

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

    public void f(int i2) {
        this.f4930c = i2;
        f fVar = this.f4929b;
        g(fVar != null ? fVar.c(this.f4928a.getContext(), i2) : null);
        a();
    }

    public void g(ColorStateList colorStateList) {
        if (colorStateList != null) {
            if (this.f4931d == null) {
                this.f4931d = new j0();
            }
            j0 j0Var = this.f4931d;
            j0Var.f4980a = colorStateList;
            j0Var.f4983d = true;
        } else {
            this.f4931d = null;
        }
        a();
    }

    public void h(ColorStateList colorStateList) {
        if (this.f4932e == null) {
            this.f4932e = new j0();
        }
        j0 j0Var = this.f4932e;
        j0Var.f4980a = colorStateList;
        j0Var.f4983d = true;
        a();
    }

    public void i(PorterDuff.Mode mode) {
        if (this.f4932e == null) {
            this.f4932e = new j0();
        }
        j0 j0Var = this.f4932e;
        j0Var.f4981b = mode;
        j0Var.f4982c = true;
        a();
    }
}
