package defpackage;

import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.graphics.Typeface;
import android.os.Handler;
import android.os.Looper;
import android.util.SparseArray;
import android.util.TypedValue;
import java.io.IOException;
import java.util.WeakHashMap;
import org.xmlpull.v1.XmlPullParserException;

/* JADX INFO: renamed from: ʿʚᵤˆ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes3.dex */
public abstract class AbstractC0354 {

    /* JADX INFO: renamed from: ᵲᵶᵳˈ, reason: contains not printable characters */
    public static final ThreadLocal f2145 = new ThreadLocal();

    /* JADX INFO: renamed from: ʽˈˋ, reason: contains not printable characters */
    public static final WeakHashMap f2143 = new WeakHashMap(0);

    /* JADX INFO: renamed from: ːˏᵟᵯ, reason: contains not printable characters */
    public static final Object f2144 = new Object();

    /* JADX WARN: Removed duplicated region for block: B:39:0x00b2  */
    /* JADX INFO: renamed from: ʽˈˋ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static Typeface m1673(Context context, int i, TypedValue typedValue, int i2, C0760 c0760, boolean z) {
        int i3;
        C0760 c07602;
        Resources resources = context.getResources();
        resources.getValue(i, typedValue, true);
        CharSequence charSequence = typedValue.string;
        if (charSequence == null) {
            throw new Resources.NotFoundException("Resource \"" + resources.getResourceName(i) + "\" (" + Integer.toHexString(i) + ") is not a Font: " + typedValue);
        }
        String string = charSequence.toString();
        Typeface typefaceM7279 = null;
        if (string.startsWith("res/")) {
            int i4 = typedValue.assetCookie;
            C1935 c1935 = AbstractC3170.f12039;
            Typeface typeface = (Typeface) c1935.m5189(AbstractC3170.m7277(resources, i, string, i4, i2));
            int i5 = 14;
            if (typeface != null) {
                if (c0760 != null) {
                    new Handler(Looper.getMainLooper()).post(new RunnableC2093(c0760, i5, typeface));
                }
                i3 = i;
                c07602 = c0760;
                typefaceM7279 = typeface;
            } else {
                try {
                } catch (IOException | XmlPullParserException unused) {
                    i3 = i;
                    c07602 = c0760;
                }
                if (string.toLowerCase().endsWith(".xml")) {
                    try {
                        InterfaceC0278 interfaceC0278M2521 = AbstractC0702.m2521(resources.getXml(i), resources);
                        if (interfaceC0278M2521 != null) {
                            c07602 = c0760;
                            try {
                                typefaceM7279 = AbstractC3170.m7279(context, interfaceC0278M2521, resources, i, string, typedValue.assetCookie, i2, c07602, z);
                                i3 = i;
                            } catch (IOException | XmlPullParserException unused2) {
                                i3 = i;
                                if (c07602 != null) {
                                }
                            }
                        } else if (c0760 != null) {
                            c0760.m2732();
                        }
                    } catch (IOException | XmlPullParserException unused3) {
                        c07602 = c0760;
                        i3 = i;
                    }
                    if (c07602 != null) {
                        c07602.m2732();
                    }
                } else {
                    c07602 = c0760;
                    i3 = i;
                    try {
                        int i6 = typedValue.assetCookie;
                        Typeface typeface2 = AbstractC3170.f12041.ᵻʽᵯ(context, resources, i3, string, i2);
                        if (typeface2 != null) {
                            c1935.m5182(AbstractC3170.m7277(resources, i3, string, i6, i2), typeface2);
                        }
                        if (c07602 != null) {
                            if (typeface2 != null) {
                                new Handler(Looper.getMainLooper()).post(new RunnableC2093(c07602, i5, typeface2));
                            } else {
                                c07602.m2732();
                            }
                        }
                        typefaceM7279 = typeface2;
                    } catch (IOException | XmlPullParserException unused4) {
                        if (c07602 != null) {
                        }
                    }
                }
            }
            if (typefaceM7279 == null || c07602 != null) {
                return typefaceM7279;
            }
            throw new Resources.NotFoundException("Font resource ID #0x" + Integer.toHexString(i3) + " could not be retrieved.");
        }
        if (c0760 != null) {
            c0760.m2732();
        }
        i3 = i;
        c07602 = c0760;
        if (typefaceM7279 == null) {
        }
        return typefaceM7279;
    }

    /* JADX INFO: renamed from: ᵲᵶᵳˈ, reason: contains not printable characters */
    public static void m1674(C0427 c0427, int i, ColorStateList colorStateList, Resources.Theme theme) {
        synchronized (f2144) {
            try {
                WeakHashMap weakHashMap = f2143;
                SparseArray sparseArray = (SparseArray) weakHashMap.get(c0427);
                if (sparseArray == null) {
                    sparseArray = new SparseArray();
                    weakHashMap.put(c0427, sparseArray);
                }
                sparseArray.append(i, new C2560(colorStateList, c0427.f2373.getConfiguration(), theme));
            } catch (Throwable th) {
                throw th;
            }
        }
    }
}
