package a.c.d;

import a.c.c.b.c;
import a.c.c.b.f;
import a.c.f.b;
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;

/* JADX INFO: compiled from: TypefaceCompat.java */
/* JADX INFO: loaded from: classes.dex */
public class c {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    private static final h f182a;

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

    static {
        int i = Build.VERSION.SDK_INT;
        if (i >= 28) {
            f182a = new g();
        } else if (i >= 26) {
            f182a = new f();
        } else if (i >= 24 && e.j()) {
            f182a = new e();
        } else if (i >= 21) {
            f182a = new d();
        } else {
            f182a = new h();
        }
        f183b = new a.b.d<>(16);
    }

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

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

    public static Typeface c(Context context, Resources resources, int i, String str, int i2) {
        Typeface typefaceD = f182a.d(context, resources, i, str, i2);
        if (typefaceD != null) {
            f183b.d(d(resources, i, i2), typefaceD);
        }
        return typefaceD;
    }

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

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