當前位置: 首頁>>代碼示例>>Java>>正文


Java Resources.getConfiguration方法代碼示例

本文整理匯總了Java中android.content.res.Resources.getConfiguration方法的典型用法代碼示例。如果您正苦於以下問題:Java Resources.getConfiguration方法的具體用法?Java Resources.getConfiguration怎麽用?Java Resources.getConfiguration使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.content.res.Resources的用法示例。


在下文中一共展示了Resources.getConfiguration方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: applyLocale

import android.content.res.Resources; //導入方法依賴的package包/類
@Override
public void applyLocale() {
    Context context = getContext();
    final LocaleManager localeManager = LocaleManager.getInstance();
    if (!localeManager.isMirroringSystemLocale(context)) {
        final Locale currentLocale = localeManager.getCurrentLocale(context);
        Locale.setDefault(currentLocale);
        final Resources resources = context.getResources();
        final Configuration config = resources.getConfiguration();
        config.setLocale(currentLocale);
        context.getResources().updateConfiguration(config, null);
    }
    // We create and destroy a new WebView here to force the internal state of WebView to know
    // about the new language. See issue #666.
    final WebView unneeded = new WebView(getContext());
    unneeded.destroy();
}
 
開發者ID:mozilla-mobile,項目名稱:firefox-tv,代碼行數:18,代碼來源:WebFragment.java

示例2: updateConfigurationForNightMode

import android.content.res.Resources; //導入方法依賴的package包/類
private boolean updateConfigurationForNightMode(int mode) {
    Resources res = this.mContext.getResources();
    Configuration conf = res.getConfiguration();
    int currentNightMode = conf.uiMode & 48;
    int newNightMode = 0;
    switch (mode) {
        case 1:
            newNightMode = 16;
            break;
        case 2:
            newNightMode = 32;
            break;
    }
    if (currentNightMode == newNightMode) {
        return false;
    }
    conf.uiMode = (conf.uiMode & -49) | newNightMode;
    res.updateConfiguration(conf, null);
    return true;
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:21,代碼來源:AppCompatDelegateImplV14.java

示例3: say

import android.content.res.Resources; //導入方法依賴的package包/類
/**
 * get String out of a string-value file
 *
 * @param resourceId id of string
 * @param useTTSLanguage set to true if the string should be said in the current language of the tts engine
 *
 * */
public Future say(Integer resourceId, Boolean useTTSLanguage) {

    if(useTTSLanguage) {
        Resources standardResources = session.getContext().getResources();
        AssetManager assets = standardResources.getAssets();
        DisplayMetrics metrics = standardResources.getDisplayMetrics();
        Configuration config = new Configuration(standardResources.getConfiguration());
        try {
            config.locale = LANGUAGE_TO_LOCALE.get((String) this.getLanguage().get());
            Resources defaultResources = new Resources(assets, metrics, config);
            String text = defaultResources.getString(resourceId);
            return this.say(text);
        } catch (ExecutionException e) {
            Log.d("PepperAndroid.Say", e.getMessage());
        }
    }

    // Fallback to default language
    return this.say(this.session.getContext().getResources().getString(resourceId));


}
 
開發者ID:LilithWittmann,項目名稱:pepper-android,代碼行數:30,代碼來源:Say.java

示例4: updateResourcesLegacy

import android.content.res.Resources; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
private static Context updateResourcesLegacy(Context context, String language) {
	Locale locale = new Locale(language);
	Locale.setDefault(locale);

	Resources resources = context.getResources();

	Configuration configuration = resources.getConfiguration();
	configuration.locale = locale;
	if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
		configuration.setLayoutDirection(locale);
	}

	resources.updateConfiguration(configuration, resources.getDisplayMetrics());

	return context;
}
 
開發者ID:joaomneto,項目名稱:TitanCompanion,代碼行數:18,代碼來源:LocaleHelper.java

示例5: getNavigationBarHeight

import android.content.res.Resources; //導入方法依賴的package包/類
/**
 * 獲取虛擬導航欄高度
 *
 * @param context Context
 * @return 虛擬導航欄高度
 */
@TargetApi(14)
public static int getNavigationBarHeight(Context context) {
    Resources res = context.getResources();
    int result = 0;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        if (hasNavBar(context)) {
            String key;
            if (res.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
                key = NAV_BAR_HEIGHT_RES_NAME;
            } else {
                key = NAV_BAR_HEIGHT_LANDSCAPE_RES_NAME;
            }
            return getInternalDimensionSize(res, key);
        }
    }
    return result;
}
 
開發者ID:Pingsh,項目名稱:Mix,代碼行數:24,代碼來源:SystemUtil.java

示例6: updateRamBarLayout

import android.content.res.Resources; //導入方法依賴的package包/類
@SuppressLint("RtlHardcoded")
private static void updateRamBarLayout() {
    if (mRamUsageBar == null || mRamBarGravity == 0) return;

    final Context context = mRamUsageBar.getContext();
    final Resources res = mRamUsageBar.getResources();
    final int orientation = res.getConfiguration().orientation;
    final boolean caOnTop = (mButtonGravity & Gravity.TOP) == Gravity.TOP;
    final boolean caOnLeft = (mButtonGravity & Gravity.LEFT) == Gravity.LEFT;
    final boolean rbOnTop = (mRamBarGravity == Gravity.TOP);
    final int marginTop = rbOnTop ? mMarginTopPx : 0;
    final int marginBottom = (!rbOnTop && (orientation == Configuration.ORIENTATION_PORTRAIT ||
            !Utils.isPhoneUI(context))) ? mMarginBottomPx : 0;
    final int marginLeft = orientation == Configuration.ORIENTATION_LANDSCAPE &&
            Utils.isPhoneUI(context) & mNavbarLeftHanded ? mMarginBottomPx : 0;
    final int marginRight = orientation == Configuration.ORIENTATION_LANDSCAPE &&
            Utils.isPhoneUI(context) & !mNavbarLeftHanded ? mMarginBottomPx : 0;

    FrameLayout.LayoutParams flp = (FrameLayout.LayoutParams) mRamUsageBar.getLayoutParams();
    flp.gravity = mRamBarGravity;
    flp.setMargins(mRamUsageBarHorizontalMargin + marginLeft,
            rbOnTop ? (mRamUsageBarVerticalMargin + marginTop) : 0,
            mRamUsageBarHorizontalMargin + marginRight,
            rbOnTop ? 0 : (mRamUsageBarVerticalMargin + marginBottom)
    );
    mRamUsageBar.setLayoutParams(flp);
    if (DEBUG) log("RAM bar layout updated");
}
 
開發者ID:WrBug,項目名稱:GravityBox,代碼行數:29,代碼來源:ModClearAllRecents.java

示例7: getResources

import android.content.res.Resources; //導入方法依賴的package包/類
@Override
public Resources getResources(Context context, ApplicationInfo appInfo) throws Exception {
    AppSetting appSetting = VAppManagerService.get().findAppInfo(appInfo.packageName);
    if (appSetting != null) {
        AssetManager assets = mirror.android.content.res.AssetManager.ctor.newInstance();
        mirror.android.content.res.AssetManager.addAssetPath.call(assets, appSetting.apkPath);
        Resources hostRes = context.getResources();
        return new Resources(assets, hostRes.getDisplayMetrics(), hostRes.getConfiguration());
    }
    return null;
}
 
開發者ID:codehz,項目名稱:container,代碼行數:12,代碼來源:AppAccountParser.java

示例8: getAllowRotationDefaultValue

import android.content.res.Resources; //導入方法依賴的package包/類
public static boolean getAllowRotationDefaultValue(Context context) {
    if (isNycOrAbove()) {
        // If the device was scaled, used the original dimensions to determine if rotation
        // is allowed of not.
        Resources res = context.getResources();
        int originalSmallestWidth = res.getConfiguration().smallestScreenWidthDp
                * res.getDisplayMetrics().densityDpi / DisplayMetrics.DENSITY_DEVICE_STABLE;
        return originalSmallestWidth >= 600;
    }
    return false;
}
 
開發者ID:michelelacorte,項目名稱:FlickLauncher,代碼行數:12,代碼來源:Utilities.java

示例9: getResources

import android.content.res.Resources; //導入方法依賴的package包/類
@CheckResult
public static Resources getResources(Context context, String apkPath) {
    try {
        AssetManager assetManager = getAssetManager(apkPath);
        Resources resources = context.getResources();
        return new Resources(assetManager, resources.getDisplayMetrics(), resources.getConfiguration());
    } catch (Exception e) {
        e.printStackTrace();
    }

    return null;
}
 
開發者ID:XaskYSab,項目名稱:CSkin,代碼行數:13,代碼來源:RecourcesUtil.java

示例10: updateResources

import android.content.res.Resources; //導入方法依賴的package包/類
@SuppressLint("NewApi")
private static void updateResources(Context context, String language) {
    Locale locale = new Locale(language);
    Locale.setDefault(locale);

    Resources resources = context.getResources();

    Configuration configuration = resources.getConfiguration();
    configuration.setLocale(locale);
    resources.updateConfiguration(configuration,null);
}
 
開發者ID:afiqiqmal,項目名稱:My-Android-Base-Code,代碼行數:12,代碼來源:LanguageLocalHelper.java

示例11: updateConfiguration

import android.content.res.Resources; //導入方法依賴的package包/類
private void updateConfiguration(Resources resources) {
    LogInfo.log(TAG, "updateConfiguration resources=" + resources);
    if (JarApplication.getInstance() != null && JarApplication.getInstance().getResources() != null) {
        Resources superRes = JarApplication.getInstance().getResources();
        Configuration configuration = superRes.getConfiguration();
        LogInfo.log(TAG, "updateConfiguration configuration=" + configuration);
        DisplayMetrics displayMetrics = superRes.getDisplayMetrics();
        if (resources != null && configuration != null && displayMetrics != null) {
            resources.updateConfiguration(configuration, displayMetrics);
        }
    }
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:13,代碼來源:AdViewProxy.java

示例12: SystemBarConfig

import android.content.res.Resources; //導入方法依賴的package包/類
private SystemBarConfig(Activity activity, boolean translucentStatusBar, boolean traslucentNavBar) {
    Resources res = activity.getResources();
    mInPortrait = (res.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT);
    mSmallestWidthDp = getSmallestWidthDp(activity);
    mStatusBarHeight = getInternalDimensionSize(res, STATUS_BAR_HEIGHT_RES_NAME);
    mActionBarHeight = getActionBarHeight(activity);
    mNavigationBarHeight = getNavigationBarHeight(activity);
    mNavigationBarWidth = getNavigationBarWidth(activity);
    mHasNavigationBar = (mNavigationBarHeight > 0);
    mTranslucentStatusBar = translucentStatusBar;
    mTranslucentNavBar = traslucentNavBar;
}
 
開發者ID:TommyLemon,項目名稱:APIJSON-Android-RxJava,代碼行數:13,代碼來源:SystemBarTintManager.java

示例13: updateResources

import android.content.res.Resources; //導入方法依賴的package包/類
private static Context updateResources(Context context, String language) {
    Locale locale = new Locale(language);
    Locale.setDefault(locale);

    Resources res = context.getResources();
    Configuration config = new Configuration(res.getConfiguration());
    if (Build.VERSION.SDK_INT >= 17) {
        config.setLocale(locale);
        context = context.createConfigurationContext(config);
    } else {
        config.locale = locale;
        res.updateConfiguration(config, res.getDisplayMetrics());
    }
    return context;
}
 
開發者ID:YarikSOffice,項目名稱:LanguageTest,代碼行數:16,代碼來源:LocaleManager.java

示例14: setLocale

import android.content.res.Resources; //導入方法依賴的package包/類
public  void setLocale(String lang) {
    Locale myLocale = new Locale(lang);
    Resources res = getResources();
    DisplayMetrics dm = res.getDisplayMetrics();
    Configuration conf = res.getConfiguration();
    conf.locale = myLocale;
    res.updateConfiguration(conf, dm);
    Intent refresh = new Intent(getContext(), MainActivity.class);
    startActivity(refresh);
    getActivity().finish();
}
 
開發者ID:jcolladosp,項目名稱:PimPam,代碼行數:12,代碼來源:SettingsFragment.java

示例15: setResourcesLocale

import android.content.res.Resources; //導入方法依賴的package包/類
/**
 * Set the current locale for the resources (strings, ...).
 */
public static void setResourcesLocale(Locale locale, Context context) {
    Resources resources = context.getResources();
    resources.getConfiguration().locale = locale;
    resources.updateConfiguration(resources.getConfiguration(), null);
}
 
開發者ID:marcplouhinec,項目名稱:speaking-glasses,代碼行數:9,代碼來源:LocaleUtils.java


注:本文中的android.content.res.Resources.getConfiguration方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。