package c.f.e;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Typeface;
import android.os.Build;
import android.os.CancellationSignal;
import android.os.Handler;
import c.f.d.c.c;
import c.f.d.c.f;
import c.f.i.b;

/* JADX INFO: compiled from: TypefaceCompat.java */
/* JADX INFO: loaded from: classes.dex */
@SuppressLint({"NewApi"})
public class d {
    private static final j a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    private static final c.d.e<String, Typeface> f1379b;

    static {
        int i2 = Build.VERSION.SDK_INT;
        if (i2 >= 29) {
            a = new i();
        } else if (i2 >= 28) {
            a = new h();
        } else if (i2 >= 26) {
            a = new g();
        } else if (i2 >= 24 && f.l()) {
            a = new f();
        } else if (Build.VERSION.SDK_INT >= 21) {
            a = new e();
        } else {
            a = new j();
        }
        f1379b = new c.d.e<>(16);
    }

    public static Typeface a(Context context, CancellationSignal cancellationSignal, b.f[] fVarArr, int i2) {
        return a.c(context, cancellationSignal, fVarArr, i2);
    }

    public static Typeface b(Context context, c.a aVar, Resources resources, int i2, int i3, f.a aVar2, Handler handler, boolean z) {
        Typeface typefaceB;
        if (aVar instanceof c.d) {
            c.d dVar = (c.d) aVar;
            boolean z2 = false;
            if (!z ? aVar2 == null : dVar.a() == 0) {
                z2 = true;
            }
            typefaceB = c.f.i.b.g(context, dVar.b(), aVar2, handler, z2, z ? dVar.c() : -1, i3);
        } else {
            typefaceB = a.b(context, (c.b) aVar, resources, i3);
            if (aVar2 != null) {
                if (typefaceB != null) {
                    aVar2.b(typefaceB, handler);
                } else {
                    aVar2.a(-3, handler);
                }
            }
        }
        if (typefaceB != null) {
            f1379b.d(d(resources, i2, i3), typefaceB);
        }
        return typefaceB;
    }

    public static Typeface c(Context context, Resources resources, int i2, String str, int i3) {
        Typeface typefaceE = a.e(context, resources, i2, str, i3);
        if (typefaceE != null) {
            f1379b.d(d(resources, i2, i3), typefaceE);
        }
        return typefaceE;
    }

    private static String d(Resources resources, int i2, int i3) {
        return resources.getResourcePackageName(i2) + "-" + i2 + "-" + i3;
    }

    public static Typeface e(Resources resources, int i2, int i3) {
        return f1379b.c(d(resources, i2, i3));
    }
}
