Java Code Examples for org.telegram.ui.ActionBar.Theme#setCurrentNightTheme()

The following examples show how to use org.telegram.ui.ActionBar.Theme#setCurrentNightTheme() . 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: ThemesHorizontalListCell.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
public void selectTheme(Theme.ThemeInfo themeInfo) {
    if (themeInfo.info != null) {
        if (!themeInfo.themeLoaded) {
            return;
        }
        if (themeInfo.info.document == null) {
            presentFragment(new ThemeSetUrlActivity(themeInfo, null, true));
            return;
        }
    }
    if (!TextUtils.isEmpty(themeInfo.assetName)) {
        Theme.PatternsLoader.createLoader(false);
    }
    if (currentType != ThemeActivity.THEME_TYPE_OTHER) {
        SharedPreferences.Editor editor = ApplicationLoader.applicationContext.getSharedPreferences("themeconfig", Activity.MODE_PRIVATE).edit();
        editor.putString(currentType == ThemeActivity.THEME_TYPE_NIGHT || themeInfo.isDark() ? "lastDarkTheme" : "lastDayTheme", themeInfo.getKey());
        editor.commit();
    }
    if (currentType == ThemeActivity.THEME_TYPE_NIGHT) {
        if (themeInfo == Theme.getCurrentNightTheme()) {
            return;
        }
        Theme.setCurrentNightTheme(themeInfo);
    } else {
        if (themeInfo == Theme.getCurrentTheme()) {
            return;
        }
        NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.needSetDayNightTheme, themeInfo, false, null, -1);
    }
    updateRows();

    int count = getChildCount();
    for (int a = 0; a < count; a++) {
        View child = getChildAt(a);
        if (child instanceof InnerThemeView) {
            ((InnerThemeView) child).updateCurrentThemeCheck();
        }
    }
}
 
Example 2
Source File: ThemesHorizontalListCell.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
public void selectTheme(Theme.ThemeInfo themeInfo) {
    if (themeInfo.info != null) {
        if (!themeInfo.themeLoaded) {
            return;
        }
        if (themeInfo.info.document == null) {
            presentFragment(new ThemeSetUrlActivity(themeInfo, null, true));
            return;
        }
    }
    if (!TextUtils.isEmpty(themeInfo.assetName)) {
        Theme.PatternsLoader.createLoader(false);
    }
    if (currentType != ThemeActivity.THEME_TYPE_OTHER) {
        SharedPreferences.Editor editor = ApplicationLoader.applicationContext.getSharedPreferences("themeconfig", Activity.MODE_PRIVATE).edit();
        editor.putString(currentType == ThemeActivity.THEME_TYPE_NIGHT || themeInfo.isDark() ? "lastDarkTheme" : "lastDayTheme", themeInfo.getKey());
        editor.commit();
    }
    if (currentType == ThemeActivity.THEME_TYPE_NIGHT) {
        if (themeInfo == Theme.getCurrentNightTheme()) {
            return;
        }
        Theme.setCurrentNightTheme(themeInfo);
    } else {
        if (themeInfo == Theme.getCurrentTheme()) {
            return;
        }
        NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.needSetDayNightTheme, themeInfo, false, null, -1);
    }
    updateRows();

    int count = getChildCount();
    for (int a = 0; a < count; a++) {
        View child = getChildAt(a);
        if (child instanceof InnerThemeView) {
            ((InnerThemeView) child).updateCurrentThemeCheck();
        }
    }
}