package d.b.g;

import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.content.res.XmlResourceParser;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;
import android.util.AttributeSet;
import android.util.Log;
import android.util.TypedValue;
import android.util.Xml;
import com.ifpdos.udi.service.core.pc.R;
import d.b.g.j;
import java.lang.ref.WeakReference;
import java.util.Objects;
import java.util.WeakHashMap;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;

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

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public static p0 f2047b;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public WeakHashMap<Context, d.e.i<ColorStateList>> f2049d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public d.e.h<String, b> f2050e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public d.e.i<String> f2051f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public final WeakHashMap<Context, d.e.e<WeakReference<Drawable.ConstantState>>> f2052g = new WeakHashMap<>(0);

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public TypedValue f2053h;

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    public boolean f2054i;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public c f2055j;
    public static final PorterDuff.Mode a = PorterDuff.Mode.SRC_IN;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public static final a f2048c = new a(6);

    public static class a extends d.e.f<Integer, PorterDuffColorFilter> {
        public a(int i2) {
            super(i2);
        }
    }

    public interface b {
        Drawable a(Context context, XmlPullParser xmlPullParser, AttributeSet attributeSet, Resources.Theme theme);
    }

    public interface c {
    }

    public static synchronized p0 c() {
        if (f2047b == null) {
            f2047b = new p0();
        }
        return f2047b;
    }

    public static synchronized PorterDuffColorFilter g(int i2, PorterDuff.Mode mode) {
        PorterDuffColorFilter porterDuffColorFilterA;
        a aVar = f2048c;
        Objects.requireNonNull(aVar);
        int i3 = (i2 + 31) * 31;
        porterDuffColorFilterA = aVar.a(Integer.valueOf(mode.hashCode() + i3));
        if (porterDuffColorFilterA == null) {
            porterDuffColorFilterA = new PorterDuffColorFilter(i2, mode);
            Objects.requireNonNull(aVar);
            aVar.b(Integer.valueOf(mode.hashCode() + i3), porterDuffColorFilterA);
        }
        return porterDuffColorFilterA;
    }

    public final synchronized boolean a(Context context, long j2, Drawable drawable) {
        boolean z2;
        Drawable.ConstantState constantState = drawable.getConstantState();
        if (constantState != null) {
            d.e.e<WeakReference<Drawable.ConstantState>> eVar = this.f2052g.get(context);
            if (eVar == null) {
                eVar = new d.e.e<>();
                this.f2052g.put(context, eVar);
            }
            eVar.i(j2, new WeakReference<>(constantState));
            z2 = true;
        } else {
            z2 = false;
        }
        return z2;
    }

    public final Drawable b(Context context, int i2) {
        int i3;
        if (this.f2053h == null) {
            this.f2053h = new TypedValue();
        }
        TypedValue typedValue = this.f2053h;
        context.getResources().getValue(i2, typedValue, true);
        long j2 = (((long) typedValue.assetCookie) << 32) | ((long) typedValue.data);
        Drawable drawableD = d(context, j2);
        if (drawableD != null) {
            return drawableD;
        }
        c cVar = this.f2055j;
        LayerDrawable layerDrawableC = null;
        if (cVar != null) {
            j.a aVar = (j.a) cVar;
            if (i2 == R.drawable.abc_cab_background_top_material) {
                layerDrawableC = new LayerDrawable(new Drawable[]{e(context, R.drawable.abc_cab_background_internal_bg), e(context, R.drawable.abc_cab_background_top_mtrl_alpha)});
            } else {
                if (i2 == R.drawable.abc_ratingbar_material) {
                    i3 = R.dimen.abc_star_big;
                } else if (i2 == R.drawable.abc_ratingbar_indicator_material) {
                    i3 = R.dimen.abc_star_medium;
                } else if (i2 == R.drawable.abc_ratingbar_small_material) {
                    i3 = R.dimen.abc_star_small;
                }
                layerDrawableC = aVar.c(this, context, i3);
            }
        }
        if (layerDrawableC != null) {
            layerDrawableC.setChangingConfigurations(typedValue.changingConfigurations);
            a(context, j2, layerDrawableC);
        }
        return layerDrawableC;
    }

    public final synchronized Drawable d(Context context, long j2) {
        d.e.e<WeakReference<Drawable.ConstantState>> eVar = this.f2052g.get(context);
        if (eVar == null) {
            return null;
        }
        WeakReference<Drawable.ConstantState> weakReferenceG = eVar.g(j2, null);
        if (weakReferenceG != null) {
            Drawable.ConstantState constantState = weakReferenceG.get();
            if (constantState != null) {
                return constantState.newDrawable(context.getResources());
            }
            int iB = d.e.d.b(eVar.f2185n, eVar.f2187p, j2);
            if (iB >= 0) {
                Object[] objArr = eVar.f2186o;
                Object obj = objArr[iB];
                Object obj2 = d.e.e.f2183f;
                if (obj != obj2) {
                    objArr[iB] = obj2;
                    eVar.f2184m = true;
                }
            }
        }
        return null;
    }

    public synchronized Drawable e(Context context, int i2) {
        return f(context, i2, false);
    }

    /* JADX WARN: Code restructure failed: missing block: B:14:0x0029, code lost:
    
        if (r0 != false) goto L15;
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public synchronized android.graphics.drawable.Drawable f(android.content.Context r5, int r6, boolean r7) {
        /*
            r4 = this;
            monitor-enter(r4)
            boolean r0 = r4.f2054i     // Catch: java.lang.Throwable -> L49
            if (r0 == 0) goto L6
            goto L2b
        L6:
            r0 = 1
            r4.f2054i = r0     // Catch: java.lang.Throwable -> L49
            r1 = 2131230805(0x7f080055, float:1.8077673E38)
            android.graphics.drawable.Drawable r1 = r4.e(r5, r1)     // Catch: java.lang.Throwable -> L49
            r2 = 0
            if (r1 == 0) goto L4b
            boolean r3 = r1 instanceof d.s.a.a.b     // Catch: java.lang.Throwable -> L49
            if (r3 != 0) goto L29
            java.lang.String r3 = "android.graphics.drawable.VectorDrawable"
            java.lang.Class r1 = r1.getClass()     // Catch: java.lang.Throwable -> L49
            java.lang.String r1 = r1.getName()     // Catch: java.lang.Throwable -> L49
            boolean r1 = r3.equals(r1)     // Catch: java.lang.Throwable -> L49
            if (r1 == 0) goto L28
            goto L29
        L28:
            r0 = r2
        L29:
            if (r0 == 0) goto L4b
        L2b:
            android.graphics.drawable.Drawable r0 = r4.i(r5, r6)     // Catch: java.lang.Throwable -> L49
            if (r0 != 0) goto L35
            android.graphics.drawable.Drawable r0 = r4.b(r5, r6)     // Catch: java.lang.Throwable -> L49
        L35:
            if (r0 != 0) goto L3d
            java.lang.Object r0 = d.h.c.a.a     // Catch: java.lang.Throwable -> L49
            android.graphics.drawable.Drawable r0 = d.h.c.a.b.b(r5, r6)     // Catch: java.lang.Throwable -> L49
        L3d:
            if (r0 == 0) goto L43
            android.graphics.drawable.Drawable r0 = r4.j(r5, r6, r7, r0)     // Catch: java.lang.Throwable -> L49
        L43:
            if (r0 == 0) goto L47
            int[] r5 = d.b.g.g0.a     // Catch: java.lang.Throwable -> L49
        L47:
            monitor-exit(r4)
            return r0
        L49:
            r5 = move-exception
            goto L55
        L4b:
            r4.f2054i = r2     // Catch: java.lang.Throwable -> L49
            java.lang.IllegalStateException r5 = new java.lang.IllegalStateException     // Catch: java.lang.Throwable -> L49
            java.lang.String r6 = "This app has been built with an incorrect configuration. Please configure your build for VectorDrawableCompat."
            r5.<init>(r6)     // Catch: java.lang.Throwable -> L49
            throw r5     // Catch: java.lang.Throwable -> L49
        L55:
            monitor-exit(r4)
            throw r5
        */
        throw new UnsupportedOperationException("Method not decompiled: d.b.g.p0.f(android.content.Context, int, boolean):android.graphics.drawable.Drawable");
    }

    public synchronized ColorStateList h(Context context, int i2) {
        ColorStateList colorStateListF;
        d.e.i<ColorStateList> iVar;
        WeakHashMap<Context, d.e.i<ColorStateList>> weakHashMap = this.f2049d;
        ColorStateList colorStateListD = null;
        colorStateListF = (weakHashMap == null || (iVar = weakHashMap.get(context)) == null) ? null : iVar.f(i2, null);
        if (colorStateListF == null) {
            c cVar = this.f2055j;
            if (cVar != null) {
                colorStateListD = ((j.a) cVar).d(context, i2);
            }
            if (colorStateListD != null) {
                if (this.f2049d == null) {
                    this.f2049d = new WeakHashMap<>();
                }
                d.e.i<ColorStateList> iVar2 = this.f2049d.get(context);
                if (iVar2 == null) {
                    iVar2 = new d.e.i<>();
                    this.f2049d.put(context, iVar2);
                }
                iVar2.b(i2, colorStateListD);
            }
            colorStateListF = colorStateListD;
        }
        return colorStateListF;
    }

    public final Drawable i(Context context, int i2) {
        int next;
        d.e.h<String, b> hVar = this.f2050e;
        if (hVar == null || hVar.isEmpty()) {
            return null;
        }
        d.e.i<String> iVar = this.f2051f;
        if (iVar != null) {
            String strF = iVar.f(i2, null);
            if ("appcompat_skip_skip".equals(strF) || (strF != null && this.f2050e.getOrDefault(strF, null) == null)) {
                return null;
            }
        } else {
            this.f2051f = new d.e.i<>();
        }
        if (this.f2053h == null) {
            this.f2053h = new TypedValue();
        }
        TypedValue typedValue = this.f2053h;
        Resources resources = context.getResources();
        resources.getValue(i2, typedValue, true);
        long j2 = (((long) typedValue.assetCookie) << 32) | ((long) typedValue.data);
        Drawable drawableD = d(context, j2);
        if (drawableD != null) {
            return drawableD;
        }
        CharSequence charSequence = typedValue.string;
        if (charSequence != null && charSequence.toString().endsWith(".xml")) {
            try {
                XmlResourceParser xml = resources.getXml(i2);
                AttributeSet attributeSetAsAttributeSet = Xml.asAttributeSet(xml);
                do {
                    next = xml.next();
                    if (next == 2) {
                        break;
                    }
                } while (next != 1);
                if (next != 2) {
                    throw new XmlPullParserException("No start tag found");
                }
                String name = xml.getName();
                this.f2051f.b(i2, name);
                b bVar = this.f2050e.get(name);
                if (bVar != null) {
                    drawableD = bVar.a(context, xml, attributeSetAsAttributeSet, context.getTheme());
                }
                if (drawableD != null) {
                    drawableD.setChangingConfigurations(typedValue.changingConfigurations);
                    a(context, j2, drawableD);
                }
            } catch (Exception e2) {
                Log.e("ResourceManagerInternal", "Exception while inflating drawable", e2);
            }
        }
        if (drawableD == null) {
            this.f2051f.b(i2, "appcompat_skip_skip");
        }
        return drawableD;
    }

    public final Drawable j(Context context, int i2, boolean z2, Drawable drawable) {
        ColorStateList colorStateListH = h(context, i2);
        PorterDuff.Mode mode = null;
        if (colorStateListH != null) {
            if (g0.a(drawable)) {
                drawable = drawable.mutate();
            }
            d.h.d.k.b.h(drawable, colorStateListH);
            c cVar = this.f2055j;
            if (cVar != null) {
                if (i2 == R.drawable.abc_switch_thumb_material) {
                    mode = PorterDuff.Mode.MULTIPLY;
                }
            }
            if (mode == null) {
                return drawable;
            }
            d.h.d.k.b.i(drawable, mode);
            return drawable;
        }
        c cVar2 = this.f2055j;
        if (cVar2 != null) {
            j.a aVar = (j.a) cVar2;
            boolean z3 = true;
            if (i2 == R.drawable.abc_seekbar_track_material) {
                LayerDrawable layerDrawable = (LayerDrawable) drawable;
                Drawable drawableFindDrawableByLayerId = layerDrawable.findDrawableByLayerId(android.R.id.background);
                int iC = u0.c(context, R.attr.colorControlNormal);
                PorterDuff.Mode mode2 = j.a;
                aVar.e(drawableFindDrawableByLayerId, iC, mode2);
                aVar.e(layerDrawable.findDrawableByLayerId(android.R.id.secondaryProgress), u0.c(context, R.attr.colorControlNormal), mode2);
                aVar.e(layerDrawable.findDrawableByLayerId(android.R.id.progress), u0.c(context, R.attr.colorControlActivated), mode2);
            } else if (i2 == R.drawable.abc_ratingbar_material || i2 == R.drawable.abc_ratingbar_indicator_material || i2 == R.drawable.abc_ratingbar_small_material) {
                LayerDrawable layerDrawable2 = (LayerDrawable) drawable;
                Drawable drawableFindDrawableByLayerId2 = layerDrawable2.findDrawableByLayerId(android.R.id.background);
                int iB = u0.b(context, R.attr.colorControlNormal);
                PorterDuff.Mode mode3 = j.a;
                aVar.e(drawableFindDrawableByLayerId2, iB, mode3);
                aVar.e(layerDrawable2.findDrawableByLayerId(android.R.id.secondaryProgress), u0.c(context, R.attr.colorControlActivated), mode3);
                aVar.e(layerDrawable2.findDrawableByLayerId(android.R.id.progress), u0.c(context, R.attr.colorControlActivated), mode3);
            } else {
                z3 = false;
            }
            if (z3) {
                return drawable;
            }
        }
        if (k(context, i2, drawable) || !z2) {
            return drawable;
        }
        return null;
    }

    /* JADX WARN: Removed duplicated region for block: B:22:0x0052  */
    /* JADX WARN: Removed duplicated region for block: B:29:0x006e  */
    /* JADX WARN: Removed duplicated region for block: B:34:? A[RETURN, SYNTHETIC] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public boolean k(android.content.Context r8, int r9, android.graphics.drawable.Drawable r10) {
        /*
            r7 = this;
            d.b.g.p0$c r0 = r7.f2055j
            r1 = 1
            r2 = 0
            if (r0 == 0) goto L72
            d.b.g.j$a r0 = (d.b.g.j.a) r0
            java.util.Objects.requireNonNull(r0)
            android.graphics.PorterDuff$Mode r3 = d.b.g.j.a
            int[] r4 = r0.a
            boolean r4 = r0.a(r4, r9)
            r5 = 16842801(0x1010031, float:2.3693695E-38)
            r6 = -1
            if (r4 == 0) goto L1d
            r5 = 2130968788(0x7f0400d4, float:1.754624E38)
            goto L49
        L1d:
            int[] r4 = r0.f1984c
            boolean r4 = r0.a(r4, r9)
            if (r4 == 0) goto L29
            r5 = 2130968786(0x7f0400d2, float:1.7546235E38)
            goto L49
        L29:
            int[] r4 = r0.f1985d
            boolean r0 = r0.a(r4, r9)
            if (r0 == 0) goto L34
            android.graphics.PorterDuff$Mode r3 = android.graphics.PorterDuff.Mode.MULTIPLY
            goto L49
        L34:
            r0 = 2131230764(0x7f08002c, float:1.807759E38)
            if (r9 != r0) goto L44
            r9 = 16842800(0x1010030, float:2.3693693E-38)
            r0 = 1109603123(0x42233333, float:40.8)
            int r0 = java.lang.Math.round(r0)
            goto L4b
        L44:
            r0 = 2131230746(0x7f08001a, float:1.8077553E38)
            if (r9 != r0) goto L4d
        L49:
            r9 = r5
            r0 = r6
        L4b:
            r4 = r1
            goto L50
        L4d:
            r9 = r2
            r4 = r9
            r0 = r6
        L50:
            if (r4 == 0) goto L6e
            boolean r4 = d.b.g.g0.a(r10)
            if (r4 == 0) goto L5c
            android.graphics.drawable.Drawable r10 = r10.mutate()
        L5c:
            int r8 = d.b.g.u0.c(r8, r9)
            android.graphics.PorterDuffColorFilter r8 = d.b.g.j.c(r8, r3)
            r10.setColorFilter(r8)
            if (r0 == r6) goto L6c
            r10.setAlpha(r0)
        L6c:
            r8 = r1
            goto L6f
        L6e:
            r8 = r2
        L6f:
            if (r8 == 0) goto L72
            goto L73
        L72:
            r1 = r2
        L73:
            return r1
        */
        throw new UnsupportedOperationException("Method not decompiled: d.b.g.p0.k(android.content.Context, int, android.graphics.drawable.Drawable):boolean");
    }
}
