コード例 #1
0
  /**
   * Sets the theme of the app. If the new theme is the same as the current theme, nothing happens.
   * Otherwise, an event is sent to notify of the theme change.
   *
   * @param newTheme
   */
  public void setCurrentTheme(int newTheme) {
    if (newTheme == currentTheme) {
      return;
    }
    currentTheme = newTheme;
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    prefs.edit().putInt(PrefKeys.getColorTheme(), currentTheme).commit();

    // update color filter for logo icon (used in ActionBar activities)...
    adjustDrawableToTheme(getResources().getDrawable(R.drawable.search_w));

    bus.post(new ThemeChangeEvent());
  }