Example usage for android.content.res Resources Resources

List of usage examples for android.content.res Resources Resources

Introduction

In this page you can find the example usage for android.content.res Resources Resources.

Prototype

@Deprecated
public Resources(AssetManager assets, DisplayMetrics metrics, Configuration config) 

Source Link

Document

Create a new Resources object on top of an existing set of assets in an AssetManager.

Usage

From source file:Main.java

static private void resetLocale(Resources res) {
    Configuration conf = new Configuration(res.getConfiguration());
    conf.locale = mCurLocale;/*  w  w  w  .ja v a 2  s. c  o m*/
    new Resources(res.getAssets(), res.getDisplayMetrics(), conf);
}

From source file:Main.java

public static Resources createResources(Context context, AssetManager assetManager) {
    Resources superRes = context.getResources();
    return new Resources(assetManager, superRes.getDisplayMetrics(), superRes.getConfiguration());
}

From source file:com.ryg.dynamicload.DLProxyFragmentActivity.java

protected void loadResources() {
    try {//from   w  ww .j ava  2  s  . co m
        AssetManager assetManager = AssetManager.class.newInstance();
        Method addAssetPath = assetManager.getClass().getMethod("addAssetPath", String.class);
        addAssetPath.invoke(assetManager, mDexPath);
        mAssetManager = assetManager;
    } catch (Exception e) {
        e.printStackTrace();
    }
    Resources superRes = super.getResources();
    mResources = new Resources(mAssetManager, superRes.getDisplayMetrics(), superRes.getConfiguration());
}

From source file:com.jarklee.materialdatetimepicker.Utils.java

public static String getStringFromLocale(@NonNull Context context, @StringRes int strRes, Locale locale) {
    if (locale == null) {
        return context.getString(strRes);
    }/* w  w  w . j  a  va2 s .  co m*/
    Resources standardResources = context.getResources();
    AssetManager assets = standardResources.getAssets();
    DisplayMetrics metrics = standardResources.getDisplayMetrics();
    Configuration config = new Configuration(standardResources.getConfiguration());
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        config.setLocale(locale);
    } else {
        config.locale = locale;
    }
    Resources defaultResources = new Resources(assets, metrics, config);
    try {
        return defaultResources.getString(strRes);
    } catch (Exception e) {
        return context.getString(strRes);
    }
}

From source file:com.mk4droid.IMC_Activities.Fragment_Comments.java

private Resources setResources() {
    SharedPreferences mshPrefs = PreferenceManager.getDefaultSharedPreferences(ctx);
    LangSTR = mshPrefs.getString("LanguageAR", Constants_API.DefaultLanguage);
    UserNameSTR = mshPrefs.getString("UserNameAR", "");
    PasswordSTR = mshPrefs.getString("PasswordAR", "");
    IssuesNoSTR = mshPrefs.getString("IssuesNoAR", "40");
    AuthFlag = mshPrefs.getBoolean("AuthFlag", false);

    if (!Service_Data.HasInternet)
        AuthFlag = false;//  ww w.  j a v  a  2s.c  om

    UserID_STR = mshPrefs.getString("UserID_STR", "");

    Configuration conf = getResources().getConfiguration();
    conf.locale = new Locale(LangSTR.substring(0, 2)); //----- Convert Greek -> el ---------
    metrics = new DisplayMetrics();
    getActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics);
    return new Resources(getActivity().getAssets(), metrics, conf);
}

From source file:com.mk4droid.IMC_Activities.Fragment_List.java

private Resources setResources() {

    LangSTR = mshPrefs.getString("LanguageAR", Constants_API.DefaultLanguage);
    OpenSW = mshPrefs.getBoolean("OpenSW", true);
    AckSW = mshPrefs.getBoolean("AckSW", true);
    ClosedSW = mshPrefs.getBoolean("ClosedSW", true);
    UserID_STR = mshPrefs.getString("UserID_STR", "");
    MyIssuesSW = mshPrefs.getBoolean("MyIssuesSW", false);

    if (UserID_STR.length() > 0)
        UserID = Integer.parseInt(UserID_STR);
    else/*from www  .j  a v  a 2 s .com*/
        UserID = -1;

    Configuration conf = getResources().getConfiguration();
    conf.locale = new Locale(LangSTR.substring(0, 2)); //----- Convert Greek -> el ---------
    DisplayMetrics metrics = new DisplayMetrics();
    getActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics);
    return new Resources(getActivity().getAssets(), metrics, conf);
}

From source file:com.mk4droid.IMC_Activities.Fragment_Filters.java

private Resources setResources() {
    SharedPreferences mshPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
    LangSTR = mshPrefs.getString("LanguageAR", Constants_API.DefaultLanguage);
    OpenSW = mshPrefs.getBoolean("OpenSW", true);
    AckSW = mshPrefs.getBoolean("AckSW", true);
    ClosedSW = mshPrefs.getBoolean("ClosedSW", true);

    Configuration conf = getActivity().getResources().getConfiguration();
    conf.locale = new Locale(LangSTR.substring(0, 2)); //----- Convert Greek -> el ---------
    DisplayMetrics metrics = new DisplayMetrics();
    getActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics);
    return new Resources(ctx.getAssets(), metrics, conf);
}

From source file:com.mk4droid.IMC_Activities.Fragment_NewIssueB.java

private Resources SetResources() {

    String LangSTR = mshPrefs.getString("LanguageAR", Constants_API.DefaultLanguage);
    UserID_STR = mshPrefs.getString("UserID_STR", "");

    UserNameSTR = mshPrefs.getString("UserNameAR", "");
    PasswordSTR = mshPrefs.getString("PasswordAR", "");

    Configuration conf = getResources().getConfiguration();
    conf.locale = new Locale(LangSTR.substring(0, 2)); //----- Convert Greek -> el ---------
    metrics = new DisplayMetrics();
    getActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics);
    return new Resources(getActivity().getAssets(), metrics, conf);
}

From source file:com.mk4droid.IMC_Activities.FActivity_TabHost.java

private Resources SetResources() {
    SharedPreferences mshPrefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());

    My_System_Utils.CheckPrefs(mshPrefs);

    LangSTR = mshPrefs.getString("LanguageAR", Constants_API.DefaultLanguage);
    RefrateAR = Integer.parseInt(mshPrefs.getString("RefrateAR", "5"));

    conf = getResources().getConfiguration();
    conf.locale = new Locale(LangSTR.substring(0, 2)); // ----- Convert
    // Greek -> el
    // ---------/*from   w w w .  j  a  va  2 s.  c o m*/
    metrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(metrics);
    return new Resources(getAssets(), metrics, conf);
}

From source file:com.mk4droid.IMC_Activities.Fragment_NewIssueA.java

/**
 * Obtain resources from preferences /*ww  w  .j  av a2 s.com*/
 * @return
 */
public Resources SetResources() {
    String LangSTR = mshPrefs.getString("LanguageAR", Constants_API.DefaultLanguage);
    AuthFlag = mshPrefs.getBoolean("AuthFlag", false);

    Configuration conf = getResources().getConfiguration();
    conf.locale = new Locale(LangSTR.substring(0, 2)); //----- Convert Greek -> el ---------
    metrics = new DisplayMetrics();
    getActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics);
    return new Resources(getActivity().getAssets(), metrics, conf);
}