Java Code Examples for android.support.v7.preference.TwoStatePreference#setOnPreferenceChangeListener()
The following examples show how to use
android.support.v7.preference.TwoStatePreference#setOnPreferenceChangeListener() .
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: SettingsActivity.java From Camera-Roll-Android-App with Apache License 2.0 | 5 votes |
private void initMediaRetrieverPref(boolean storageRetriever) { TwoStatePreference mediaRetrieverPref = (TwoStatePreference) findPreference(getString(R.string.pref_key_media_retriever)); mediaRetrieverPref.setChecked(storageRetriever); mediaRetrieverPref.setOnPreferenceChangeListener(this); }
Example 2
Source File: SettingsActivity.java From Camera-Roll-Android-App with Apache License 2.0 | 5 votes |
private void init8BitColorPref(boolean use8BitColor) { TwoStatePreference use8BitColorPref = (TwoStatePreference) findPreference(getString(R.string.pref_key_8_bit_color)); use8BitColorPref.setChecked(use8BitColor); use8BitColorPref.setOnPreferenceChangeListener(this); }
Example 3
Source File: SettingsActivity.java From Camera-Roll-Android-App with Apache License 2.0 | 5 votes |
private void initCameraShortcutPref(boolean cameraShortcut) { TwoStatePreference cameraShortcutPref = (TwoStatePreference) findPreference(getString(R.string.pref_key_camera_shortcut)); cameraShortcutPref.setChecked(cameraShortcut); cameraShortcutPref.setOnPreferenceChangeListener(this); }
Example 4
Source File: SettingsActivity.java From Camera-Roll-Android-App with Apache License 2.0 | 5 votes |
private void initAnimationsPref(boolean showAnimations) { TwoStatePreference animationsPref = (TwoStatePreference) findPreference(getString(R.string.pref_key_animations)); animationsPref.setChecked(showAnimations); animationsPref.setOnPreferenceChangeListener(this); }
Example 5
Source File: SettingsActivity.java From Camera-Roll-Android-App with Apache License 2.0 | 5 votes |
private void initMaxBrightnessPref(boolean maxBrightness) { TwoStatePreference animationsPref = (TwoStatePreference) findPreference(getString(R.string.pref_key_max_brightness)); animationsPref.setChecked(maxBrightness); animationsPref.setOnPreferenceChangeListener(this); }
Example 6
Source File: SettingsActivity.java From RetroMusicPlayer with GNU General Public License v3.0 | 4 votes |
private void invalidateSettings() { Preference findPreference = findPreference("changelog"); findPreference.setOnPreferenceClickListener(preference -> { openUrl(Constants.TELEGRAM_CHANGE_LOG); return true; }); findPreference = findPreference("day_dream"); findPreference.setVisible(false); findPreference.setOnPreferenceClickListener(preference -> { Intent intent = new Intent(Settings.ACTION_DREAM_SETTINGS); startActivity(intent); return true; }); findPreference = findPreference("user_info"); findPreference.setOnPreferenceClickListener(preference -> { startActivity(new Intent(getContext(), UserInfoActivity.class)); return true; }); findPreference = findPreference("open_source"); findPreference.setOnPreferenceClickListener(preference -> { showLicenseDialog(); return true; }); findPreference = findPreference("about"); findPreference.setOnPreferenceClickListener(preference -> { startActivity(new Intent(getContext(), AboutActivity.class)); return true; }); findPreference = findPreference("app_version"); try { PackageInfo packageInfo = getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), 0); findPreference.setSummary(packageInfo.versionName); } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } TwoStatePreference toggleVolume = (TwoStatePreference) findPreference("toggle_volume"); toggleVolume.setOnPreferenceChangeListener((preference, o) -> { Toast.makeText(getContext(), "Restart app!", Toast.LENGTH_SHORT).show(); getActivity().recreate(); return true; }); TwoStatePreference colorAppShortcuts = (TwoStatePreference) findPreference("should_color_app_shortcuts"); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N_MR1) { colorAppShortcuts.setVisible(false); } else { colorAppShortcuts.setChecked(PreferenceUtil.getInstance(getActivity()).coloredAppShortcuts()); colorAppShortcuts.setOnPreferenceChangeListener((preference, newValue) -> { // Save preference PreferenceUtil.getInstance(getActivity()).setColoredAppShortcuts((Boolean) newValue); // Update app shortcuts new DynamicShortcutManager(getActivity()).updateDynamicShortcuts(); return true; }); } TwoStatePreference cornerWindow = (TwoStatePreference) findPreference("corner_window"); cornerWindow.setOnPreferenceChangeListener((preference, newValue) -> { Toast.makeText(getContext(), "Restart app!", Toast.LENGTH_SHORT).show(); getActivity().recreate(); return true; }); }