package androidx.core.graphics;

import android.content.Context;
import android.content.res.Resources;
import android.graphics.Typeface;
import android.os.CancellationSignal;
import android.os.Handler;
import androidx.collection.u;
import androidx.core.content.res.e;
import androidx.core.content.res.h;
import q3.g;

/* loaded from: classes.dex */
public abstract class e {

    /* renamed from: a, reason: collision with root package name */
    private static final g f3744a = new f();

    /* renamed from: b, reason: collision with root package name */
    private static final u f3745b = new u(16);

    /* loaded from: classes.dex */
    public static class a extends g.c {

        /* renamed from: a, reason: collision with root package name */
        private h.e f3746a;

        public a(h.e eVar) {
            this.f3746a = eVar;
        }

        @Override // q3.g.c
        public void a(int i10) {
            h.e eVar = this.f3746a;
            if (eVar != null) {
                eVar.f(i10);
            }
        }

        @Override // q3.g.c
        public void b(Typeface typeface) {
            h.e eVar = this.f3746a;
            if (eVar != null) {
                eVar.g(typeface);
            }
        }
    }

    public static Typeface a(Context context, Typeface typeface, int i10) {
        if (context != null) {
            return Typeface.create(typeface, i10);
        }
        throw new IllegalArgumentException("Context cannot be null");
    }

    public static Typeface b(Context context, CancellationSignal cancellationSignal, g.b[] bVarArr, int i10) {
        return f3744a.b(context, cancellationSignal, bVarArr, i10);
    }

    public static Typeface c(Context context, e.b bVar, Resources resources, int i10, String str, int i11, int i12, h.e eVar, Handler handler, boolean z10) {
        Typeface a10;
        if (bVar instanceof e.C0094e) {
            e.C0094e c0094e = (e.C0094e) bVar;
            Typeface g10 = g(c0094e.c());
            if (g10 != null) {
                if (eVar != null) {
                    eVar.d(g10, handler);
                }
                return g10;
            }
            boolean z11 = !z10 ? eVar != null : c0094e.a() != 0;
            int d10 = z10 ? c0094e.d() : -1;
            a10 = q3.g.c(context, c0094e.b(), i12, z11, d10, h.e.e(handler), new a(eVar));
        } else {
            a10 = f3744a.a(context, (e.c) bVar, resources, i12);
            if (eVar != null) {
                if (a10 != null) {
                    eVar.d(a10, handler);
                } else {
                    eVar.c(-3, handler);
                }
            }
        }
        if (a10 != null) {
            f3745b.put(e(resources, i10, str, i11, i12), a10);
        }
        return a10;
    }

    public static Typeface d(Context context, Resources resources, int i10, String str, int i11, int i12) {
        Typeface c10 = f3744a.c(context, resources, i10, str, i12);
        if (c10 != null) {
            f3745b.put(e(resources, i10, str, i11, i12), c10);
        }
        return c10;
    }

    private static String e(Resources resources, int i10, String str, int i11, int i12) {
        return resources.getResourcePackageName(i10) + '-' + str + '-' + i11 + '-' + i10 + '-' + i12;
    }

    public static Typeface f(Resources resources, int i10, String str, int i11, int i12) {
        return (Typeface) f3745b.get(e(resources, i10, str, i11, i12));
    }

    private static Typeface g(String str) {
        if (str == null || str.isEmpty()) {
            return null;
        }
        Typeface create = Typeface.create(str, 0);
        Typeface create2 = Typeface.create(Typeface.DEFAULT, 0);
        if (create == null || create.equals(create2)) {
            return null;
        }
        return create;
    }
}
