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.widget.ImageView;

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

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

    public m(ImageView imageView) {
        this.a = imageView;
    }

    public void a() {
        x0 x0Var;
        Drawable drawable = this.a.getDrawable();
        if (drawable != null) {
            int[] iArr = g0.a;
        }
        if (drawable == null || (x0Var = this.f2021b) == null) {
            return;
        }
        j.f(drawable, x0Var, this.a.getDrawableState());
    }

    public void b(AttributeSet attributeSet, int i2) {
        int iL;
        Context context = this.a.getContext();
        int[] iArr = d.b.b.f1533f;
        z0 z0VarQ = z0.q(context, attributeSet, iArr, i2, 0);
        ImageView imageView = this.a;
        d.h.j.y.o(imageView, imageView.getContext(), iArr, attributeSet, z0VarQ.f2138b, i2, 0);
        try {
            Drawable drawable = this.a.getDrawable();
            if (drawable == null && (iL = z0VarQ.l(1, -1)) != -1 && (drawable = d.b.d.a.a.a(this.a.getContext(), iL)) != null) {
                this.a.setImageDrawable(drawable);
            }
            if (drawable != null) {
                int[] iArr2 = g0.a;
            }
            if (z0VarQ.o(2)) {
                d.h.k.g.c(this.a, z0VarQ.c(2));
            }
            if (z0VarQ.o(3)) {
                d.h.k.g.d(this.a, g0.b(z0VarQ.j(3, -1), null));
            }
            z0VarQ.f2138b.recycle();
        } catch (Throwable th) {
            z0VarQ.f2138b.recycle();
            throw th;
        }
    }

    public void c(int i2) {
        if (i2 != 0) {
            Drawable drawableA = d.b.d.a.a.a(this.a.getContext(), i2);
            if (drawableA != null) {
                int[] iArr = g0.a;
            }
            this.a.setImageDrawable(drawableA);
        } else {
            this.a.setImageDrawable(null);
        }
        a();
    }

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

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