package com.coolcloud.uac.android.api.view.basic;

import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.StateListDrawable;
import android.view.LayoutInflater;
import android.view.View;
import java.io.IOException;

public class CustomResourceMgmt {
    public static boolean ISENGLISH = false;
    protected static volatile CustomResourceMgmt myResouceMgmt;
    private AssetsUtil mAssetsUtil = AssetsUtil.getInstance(this.mContext);
    private Context mContext;
    private LayoutInflater mLayoutInflater = LayoutInflater.from(this.mContext);
    private Resources mResources = this.mContext.getResources();
    private String packageName = this.mContext.getApplicationInfo().packageName;

    private CustomResourceMgmt(Context context) {
        this.mContext = context.getApplicationContext();
    }

    public static CustomResourceMgmt get(Context context) {
        if (myResouceMgmt == null) {
            synchronized (CustomResourceMgmt.class) {
                if (myResouceMgmt == null) {
                    myResouceMgmt = new CustomResourceMgmt(context);
                }
            }
        }
        return myResouceMgmt;
    }

    public String getString(String resouceKey) {
        return this.mAssetsUtil.getString(resouceKey);
    }

    public View getLayout(String resouceKey, boolean island) {
        return (island && havelandlayout(resouceKey)) ? getLayoutLand(resouceKey) : getLayoutPort(resouceKey);
    }

    private boolean havelandlayout(String resouceKey) {
        try {
            this.mContext.getAssets().open("layout-land/" + resouceKey + ".xml");
            return true;
        } catch (IOException e) {
            e.printStackTrace();
            return false;
        }
    }

    private View getLayoutPort(String resouceKey) {
        int resouceId = this.mResources.getIdentifier(resouceKey, "layout", this.packageName);
        if (resouceId == 0) {
            return this.mAssetsUtil.getLayout("layout/" + resouceKey + ".xml", null);
        }
        return this.mLayoutInflater.inflate(resouceId, null);
    }

    private View getLayoutLand(String resouceKey) {
        int resouceId = this.mResources.getIdentifier(resouceKey, "layout", this.packageName);
        if (resouceId == 0) {
            return this.mAssetsUtil.getLayout("layout-land/" + resouceKey + ".xml", null);
        }
        return this.mLayoutInfla