Back to project page CATaZine-Live.
The source code is released under:
GNU General Public License
If you think the Android project CATaZine-Live listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.melegy.catazine.activity; /*from w ww . j a va2s .c om*/ import android.content.Intent; import android.os.Bundle; import android.preference.Preference; import android.preference.Preference.OnPreferenceChangeListener; import android.preference.PreferenceActivity; import android.view.MenuItem; import com.melegy.catazine.R; import com.melegy.catazine.service.RefreshService; import com.melegy.catazine.utils.PrefUtils; import com.melegy.catazine.utils.UiUtils; public class GeneralPrefsActivity extends PreferenceActivity { @Override protected void onCreate(Bundle savedInstanceState) { UiUtils.setPreferenceTheme(this); super.onCreate(savedInstanceState); getActionBar().setDisplayHomeAsUpEnabled(true); addPreferencesFromResource(R.layout.activity_preferences); Preference preference = findPreference(PrefUtils.REFRESH_ENABLED); preference.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { if (Boolean.TRUE.equals(newValue)) { startService(new Intent(GeneralPrefsActivity.this, RefreshService.class)); } else { PrefUtils.putLong(PrefUtils.LAST_SCHEDULED_REFRESH, 0); stopService(new Intent(GeneralPrefsActivity.this, RefreshService.class)); } return true; } }); preference = findPreference(PrefUtils.LIGHT_THEME); preference.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { PrefUtils.putBoolean(PrefUtils.LIGHT_THEME, Boolean.TRUE.equals(newValue)); android.os.Process.killProcess(android.os.Process.myPid()); // this return statement will never be reached return true; } }); } @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: finish(); return true; } return true; } }