package com.bytedance.sdk.component.utils;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.text.TextUtils;
import xyz.stream.download.config.InnerConstant;

/* JADX INFO: loaded from: classes.dex */
public final class maa {
    private static boolean ajl = false;

    @SuppressLint({"StaticFieldLeak"})
    private static Context fm = null;
    private static boolean jnr = false;

    /* JADX INFO: renamed from: lb, reason: collision with root package name */
    private static Resources f6686lb;
    private static String ro;
    private static String yz;

    public static int ajl(Context context, String str) {
        return fm(context, str, "style");
    }

    public static int ef(Context context, String str) {
        return fm(context, str, "anim");
    }

    public static void fm(Context context) {
        fm = context;
    }

    public static int jnr(Context context, String str) {
        return fm(context, str, InnerConstant.Db.f36069id);
    }

    public static Drawable lb(Context context, String str) {
        try {
            return ro(context).getDrawable(yz(context, str));
        } catch (Exception unused) {
            return null;
        }
    }

    public static int ro(Context context, String str) {
        return fm(context, str, "string");
    }

    public static int wsy(Context context, String str) {
        return ro(context).getColor(wu(context, str));
    }

    public static int wu(Context context, String str) {
        return fm(context, str, "color");
    }

    private static String yz(Context context) {
        if (yz == null) {
            yz = context.getPackageName();
        }
        return yz;
    }

    public static void fm(String str) {
        yz = str;
    }

    public static Resources ro(Context context) {
        Resources resources = f6686lb;
        if (resources == null) {
            resources = null;
        }
        Context context2 = fm;
        if (context2 != null) {
            resources = context2.getResources();
        }
        return resources == null ? context.getResources() : resources;
    }

    public static int yz(Context context, String str) {
        try {
            return fm(context, str, "drawable");
        } catch (Exception unused) {
            return 0;
        }
    }

    private static int fm(Context context, String str, String str2) {
        int identifier = ro(context).getIdentifier(str, str2, yz(context));
        if (identifier != 0) {
            return identifier;
        }
        if (!jnr) {
            lb(context);
            return ro(context).getIdentifier(str, str2, yz(context));
        }
        return context.getResources().getIdentifier(str, str2, yz(context));
    }

    public static synchronized void lb(Context context) {
        try {
            if (TextUtils.isEmpty(ro)) {
                return;
            }
            jnr = true;
        } catch (Throwable unused) {
        }
    }

    public static String fm(Context context, String str) {
        return ro(context).getString(ro(context, str));
    }
}
