package l;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.widget.ImageView;

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

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

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

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public int f29687c = 0;

    public g0(ImageView imageView) {
        this.f29685a = imageView;
    }

    public final void a() {
        n3 n3Var;
        ImageView imageView = this.f29685a;
        Drawable drawable = imageView.getDrawable();
        if (drawable != null) {
            p1.a(drawable);
        }
        if (drawable == null || (n3Var = this.f29686b) == null) {
            return;
        }
        c0.e(drawable, n3Var, imageView.getDrawableState());
    }

    public final void b(AttributeSet attributeSet, int i10) {
        int resourceId;
        ImageView imageView = this.f29685a;
        Context context = imageView.getContext();
        int[] iArr = d.j.AppCompatImageView;
        p3 p3VarD = p3.d(context, attributeSet, iArr, i10);
        androidx.core.view.s1.saveAttributeDataForStyleable(imageView, imageView.getContext(), iArr, attributeSet, p3VarD.f29809b, i10, 0);
        try {
            Drawable drawable = imageView.getDrawable();
            TypedArray typedArray = p3VarD.f29809b;
            if (drawable == null && (resourceId = typedArray.getResourceId(d.j.AppCompatImageView_srcCompat, -1)) != -1 && (drawable = f.a.getDrawable(imageView.getContext(), resourceId)) != null) {
                imageView.setImageDrawable(drawable);
            }
            if (drawable != null) {
                p1.a(drawable);
            }
            int i11 = d.j.AppCompatImageView_tint;
            if (typedArray.hasValue(i11)) {
                u0.i.setImageTintList(imageView, p3VarD.a(i11));
            }
            int i12 = d.j.AppCompatImageView_tintMode;
            if (typedArray.hasValue(i12)) {
                u0.i.setImageTintMode(imageView, p1.c(typedArray.getInt(i12, -1), null));
            }
            p3VarD.e();
        } catch (Throwable th) {
            p3VarD.e();
            throw th;
        }
    }

    public final void c(int i10) {
        ImageView imageView = this.f29685a;
        if (i10 != 0) {
            Drawable drawable = f.a.getDrawable(imageView.getContext(), i10);
            if (drawable != null) {
                p1.a(drawable);
            }
            imageView.setImageDrawable(drawable);
        } else {
            imageView.setImageDrawable(null);
        }
        a();
    }
}
