package p028j;

import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.RippleDrawable;
import android.os.Build;
import android.util.AttributeSet;
import android.widget.ImageView;
import p007c.C0494j;
import p013e.C0640a;
import p023h0.C0829h1;
import p032k0.C1329s;

/* renamed from: j.p */
/* loaded from: classes.dex */
public class C1171p {

    /* renamed from: a */
    public final ImageView f2854a;

    /* renamed from: b */
    public C1096e3 f2855b;

    /* renamed from: c */
    public C1096e3 f2856c;

    /* renamed from: d */
    public C1096e3 f2857d;

    /* renamed from: e */
    public int f2858e = 0;

    public C1171p(ImageView imageView) {
        this.f2854a = imageView;
    }

    /* renamed from: a */
    public final boolean m1959a(Drawable drawable) {
        if (this.f2857d == null) {
            this.f2857d = new C1096e3();
        }
        C1096e3 c1096e3 = this.f2857d;
        c1096e3.m2194a();
        ColorStateList m1613a = C1329s.m1613a(this.f2854a);
        if (m1613a != null) {
            c1096e3.f2687d = true;
            c1096e3.f2684a = m1613a;
        }
        PorterDuff.Mode m1612b = C1329s.m1612b(this.f2854a);
        if (m1612b != null) {
            c1096e3.f2686c = true;
            c1096e3.f2685b = m1612b;
        }
        if (c1096e3.f2687d || c1096e3.f2686c) {
            C1117j.m2106i(drawable, c1096e3, this.f2854a.getDrawableState());
            return true;
        }
        return false;
    }

    /* renamed from: b */
    public void m1958b() {
        if (this.f2854a.getDrawable() != null) {
            this.f2854a.getDrawable().setLevel(this.f2858e);
        }
    }

    /* renamed from: c */
    public void m1957c() {
        Drawable drawable = this.f2854a.getDrawable();
        if (drawable != null) {
            C1115i2.m2117b(drawable);
        }
        if (drawable != null) {
            if (m1948l() && m1959a(drawable)) {
                return;
            }
            C1096e3 c1096e3 = this.f2856c;
            if (c1096e3 != null) {
                C1117j.m2106i(drawable, c1096e3, this.f2854a.getDrawableState());
                return;
            }
            C1096e3 c1096e32 = this.f2855b;
            if (c1096e32 != null) {
                C1117j.m2106i(drawable, c1096e32, this.f2854a.getDrawableState());
            }
        }
    }

    /* renamed from: d */
    public ColorStateList m1956d() {
        C1096e3 c1096e3 = this.f2856c;
        if (c1096e3 != null) {
            return c1096e3.f2684a;
        }
        return null;
    }

    /* renamed from: e */
    public PorterDuff.Mode m1955e() {
        C1096e3 c1096e3 = this.f2856c;
        if (c1096e3 != null) {
            return c1096e3.f2685b;
        }
        return null;
    }

    /* renamed from: f */
    public boolean m1954f() {
        return Build.VERSION.SDK_INT < 21 || !(this.f2854a.getBackground() instanceof RippleDrawable);
    }

    /* renamed from: g */
    public void m1953g(AttributeSet attributeSet, int i) {
        int m2168m;
        Context context = this.f2854a.getContext();
        int[] iArr = C0494j.f1757P;
        C1106g3 m2160u = C1106g3.m2160u(context, attributeSet, iArr, i, 0);
        ImageView imageView = this.f2854a;
        C0829h1.m2850M(imageView, imageView.getContext(), iArr, attributeSet, m2160u.m2164q(), i, 0);
        try {
            Drawable drawable = this.f2854a.getDrawable();
            if (drawable == null && (m2168m = m2160u.m2168m(C0494j.f1761Q, -1)) != -1 && (drawable = C0640a.m3229b(this.f2854a.getContext(), m2168m)) != null) {
                this.f2854a.setImageDrawable(drawable);
            }
            if (drawable != null) {
                C1115i2.m2117b(drawable);
            }
            int i2 = C0494j.f1765R;
            if (m2160u.m2163r(i2)) {
                C1329s.m1611c(this.f2854a, m2160u.m2178c(i2));
            }
            int i3 = C0494j.f1769S;
            if (m2160u.m2163r(i3)) {
                C1329s.m1610d(this.f2854a, C1115i2.m2115d(m2160u.m2171j(i3, -1), null));
            }
        } finally {
            m2160u.m2159v();
        }
    }

    /* renamed from: h */
    public void m1952h(Drawable drawable) {
        this.f2858e = drawable.getLevel();
    }

    /* renamed from: i */
    public void m1951i(int i) {
        if (i != 0) {
            Drawable m3229b = C0640a.m3229b(this.f2854a.getContext(), i);
            if (m3229b != null) {
                C1115i2.m2117b(m3229b);
            }
            this.f2854a.setImageDrawable(m3229b);
        } else {
            this.f2854a.setImageDrawable(null);
        }
        m1957c();
    }

    /* renamed from: j */
    public void m1950j(ColorStateList colorStateList) {
        if (this.f2856c == null) {
            this.f2856c = new C1096e3();
        }
        C1096e3 c1096e3 = this.f2856c;
        c1096e3.f2684a = colorStateList;
        c1096e3.f2687d = true;
        m1957c();
    }

    /* renamed from: k */
    public void m1949k(PorterDuff.Mode mode) {
        if (this.f2856c == null) {
            this.f2856c = new C1096e3();
        }
        C1096e3 c1096e3 = this.f2856c;
        c1096e3.f2685b = mode;
        c1096e3.f2686c = true;
        m1957c();
    }

    /* renamed from: l */
    public final boolean m1948l() {
        int i = Build.VERSION.SDK_INT;
        return i > 21 ? this.f2855b != null : i == 21;
    }
}