package c.a.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 f4942a;

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

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

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

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

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

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

    public void a() {
        Drawable background = this.f4942a.getBackground();
        if (background != null) {
            boolean z = true;
            if (this.f4945d != null) {
                if (this.f4947f == null) {
                    this.f4947f = new j0();
                }
                j0 j0Var = this.f4947f;
                j0Var.f4994a = null;
                j0Var.f4997d = false;
                j0Var.f4995b = null;
                j0Var.f4996c = false;
                View view = this.f4942a;
                WeakHashMap<View, c.c.i.q> weakHashMap = c.c.i.k.f5288a;
                ColorStateList backgroundTintList = view.getBackgroundTintList();
                if (backgroundTintList != null) {
                    j0Var.f4997d = true;
                    j0Var.f4994a = backgroundTintList;
                }
                PorterDuff.Mode backgroundTintMode = this.f4942a.getBackgroundTintMode();
                if (backgroundTintMode != null) {
                    j0Var.f4996c = true;
                    j0Var.f4995b = backgroundTintMode;
                }
                if (j0Var.f4997d || j0Var.f4996c) {
                    f.e(background, j0Var, this.f4942a.getDrawableState());
                } else {
                    z = false;
                }
                if (z) {
                    return;
                }
            }
            j0 j0Var2 = this.f4946e;
            if (j0Var2 != null) {
                f.e(background, j0Var2, this.f4942a.getDrawableState());
                return;
            }
            j0 j0Var3 = this.f4945d;
            if (j0Var3 != null) {
                f.e(background, j0Var3, this.f4942a.getDrawableState());
            }
        }
    }

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

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

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

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

    public void f(int i2) {
        this.f4944c = i2;
        f fVar = this.f4943b;
        g(fVar != null ? fVar.c(this.f4942a.getContext(), i2) : null);
        a();
    }

    public void g(ColorStateList colorStateList) {
        if (colorStateList != null) {
            if (this.f4945d == null) {
                this.f4945d = new j0();
            }
            j0 j0Var = this.f4945d;
            j0Var.f4994a = colorStateList;
            j0Var.f4997d = true;
        } else {
            this.f4945d = null;
        }
        a();
    }

    public void h(ColorStateList colorStateList) {
        if (this.f4946e == null) {
            this.f4946e = new j0();
        }
        j0 j0Var = this.f4946e;
        j0Var.f4994a = colorStateList;
        j0Var.f4997d = true;
        a();
    }

    public void i(PorterDuff.Mode mode) {
        if (this.f4946e == null) {
            this.f4946e = new j0();
        }
        j0 j0Var = this.f4946e;
        j0Var.f4995b = mode;
        j0Var.f4996c = true;
        a();
    }
}
