Search in sources :

Example 1 with SettingActivity

use of io.hefuyi.listener.ui.activity.SettingActivity in project ListenerMusicPlayer by hefuyicoder.

the class SettingFragment method invalidateSettings.

public void invalidateSettings() {
    mAteKey = ((SettingActivity) getActivity()).getATEKey();
    ATEColorPreference primaryColorPref = (ATEColorPreference) findPreference("primary_color");
    primaryColorPref.setColor(Config.primaryColor(getActivity(), mAteKey), Color.BLACK);
    primaryColorPref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {

        @Override
        public boolean onPreferenceClick(Preference preference) {
            new ColorChooserDialog.Builder((SettingActivity) getActivity(), R.string.primary_color).preselect(Config.primaryColor(getActivity(), mAteKey)).show();
            return true;
        }
    });
    findPreference("dark_theme").setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {

        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            // Marks both theme configs as changed so MainActivity restarts itself on return
            Config.markChanged(getActivity(), "light_theme");
            Config.markChanged(getActivity(), "dark_theme");
            // The dark_theme preference value gets saved by Android in the default PreferenceManager.
            // It's used in getATEKey() of both the Activities.
            getActivity().recreate();
            return true;
        }
    });
}
Also used : SettingActivity(io.hefuyi.listener.ui.activity.SettingActivity) Preference(android.preference.Preference) ATEColorPreference(com.afollestad.appthemeengine.prefs.ATEColorPreference) ColorChooserDialog(com.afollestad.materialdialogs.color.ColorChooserDialog) ATEColorPreference(com.afollestad.appthemeengine.prefs.ATEColorPreference)

Aggregations

Preference (android.preference.Preference)1 ATEColorPreference (com.afollestad.appthemeengine.prefs.ATEColorPreference)1 ColorChooserDialog (com.afollestad.materialdialogs.color.ColorChooserDialog)1 SettingActivity (io.hefuyi.listener.ui.activity.SettingActivity)1