Java Code Examples for android.content.res.Resources.Theme#applyStyle()

The following examples show how to use android.content.res.Resources.Theme#applyStyle() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BubbleTextView.java    From Trebuchet with GNU General Public License v3.0 5 votes vote down vote up
private Theme getPreloaderTheme() {
    Object tag = getTag();
    int style = ((tag != null) && (tag instanceof ShortcutInfo) &&
            (((ShortcutInfo) tag).container >= 0)) ? R.style.PreloadIcon_Folder
                    : R.style.PreloadIcon;
    Theme theme = sPreloaderThemes.get(style);
    if (theme == null) {
        theme = getResources().newTheme();
        theme.applyStyle(style, true);
        sPreloaderThemes.put(style, theme);
    }
    return theme;
}
 
Example 2
Source File: BubbleTextView.java    From LB-Launcher with Apache License 2.0 5 votes vote down vote up
private Theme getPreloaderTheme() {
    Object tag = getTag();
    int style = ((tag != null) && (tag instanceof ShortcutInfo) &&
            (((ShortcutInfo) tag).container >= 0)) ? R.style.PreloadIcon_Folder
                    : R.style.PreloadIcon;
    Theme theme = sPreloaderThemes.get(style);
    if (theme == null) {
        theme = getResources().newTheme();
        theme.applyStyle(style, true);
        sPreloaderThemes.put(style, theme);
    }
    return theme;
}
 
Example 3
Source File: PreferenceActivity.java    From ContentProviderHelper with MIT License 4 votes vote down vote up
@Override
protected void onApplyThemeResource(Theme theme, int resid, boolean first) {
	theme.applyStyle(resid, true);
}
 
Example 4
Source File: CJProxyActivity.java    From CJFrameForAndroid with Apache License 2.0 4 votes vote down vote up
private void fillPluginTheme(ActivityPlugin plugin) {

        Theme pluginTheme = plugin.from().pluginRes.newTheme();
        pluginTheme.setTo(super.getTheme());
        plugin.setTheme(pluginTheme);

        PackageInfo packageInfo = plugin.from().pluginPkgInfo;
        String mClass = plugin.getTopActivityName();

        Log.i(TAG, "Before fill Plugin 's Theme,We check the plugin:info = "
                + packageInfo + "topActivityName = " + mClass);

        int defaultTheme = packageInfo.applicationInfo.theme;
        ActivityInfo curActivityInfo = null;
        for (ActivityInfo a : packageInfo.activities) {
            if (a.name.equals(mClass)) {
                curActivityInfo = a;
                if (a.theme != 0) {
                    defaultTheme = a.theme;
                } else if (defaultTheme != 0) {
                    // ignore
                } else {
                    // 支持不同系统的默认Theme
                    if (Build.VERSION.SDK_INT >= 14) {
                        defaultTheme = android.R.style.Theme_DeviceDefault;
                    } else {
                        defaultTheme = android.R.style.Theme;
                    }
                }
                break;
            }
        }

        pluginTheme.applyStyle(defaultTheme, true);

        setTheme(defaultTheme);
        if (curActivityInfo != null) {
            getWindow().setSoftInputMode(curActivityInfo.softInputMode);
        }

        if (CJConfig.usePluginTitle) {
            CharSequence title = null;
            try {
                title = CJTool.getAppName(this, plugin.getPluginPath());
            } catch (PackageManager.NameNotFoundException e) {
                e.printStackTrace();
            }
            if (title != null)
                setTitle(title);
        }

    }