From 0eb576d96541e475f31c02cd0f7689a49e96e0ff Mon Sep 17 00:00:00 2001 From: Alexey Kuznetsov Date: Sun, 9 Dec 2018 17:25:55 +0300 Subject: [PATCH] cleanups --- .../activities/SettingsActivity.java | 65 ------------------- 1 file changed, 65 deletions(-) diff --git a/app/src/main/java/com/github/axet/audiorecorder/activities/SettingsActivity.java b/app/src/main/java/com/github/axet/audiorecorder/activities/SettingsActivity.java index 5407371..7cce1a3 100644 --- a/app/src/main/java/com/github/axet/audiorecorder/activities/SettingsActivity.java +++ b/app/src/main/java/com/github/axet/audiorecorder/activities/SettingsActivity.java @@ -70,71 +70,6 @@ public class SettingsActivity extends AppCompatSettingsThemeActivity implements return ll.toArray((T[]) Array.newInstance(c, ll.size())); } - /** - * A preference value change listener that updates the preference's summary - * to reflect its new value. - */ - private static Preference.OnPreferenceChangeListener sBindPreferenceSummaryToValueListener = new Preference.OnPreferenceChangeListener() { - @Override - public boolean onPreferenceChange(Preference preference, Object value) { - String stringValue = value.toString(); - String key = preference.getKey(); - - if (preference instanceof SeekBarPreference) { - preference.setSummary(((SeekBarPreference) preference).format((Float) value)); - } else if (preference instanceof NameFormatPreferenceCompat) { - preference.setSummary(((NameFormatPreferenceCompat) preference).getFormatted(stringValue)); - } else if (preference instanceof ListPreference) { - // For list preferences, look up the correct display value in - // the preference's 'entries' list. - ListPreference listPreference = (ListPreference) preference; - int index = listPreference.findIndexOfValue(stringValue); - - // Set the summary to reflect the new value. - preference.setSummary( - index >= 0 - ? listPreference.getEntries()[index] - : null); - - } else { - // For all other preferences, set the summary to the value's - // simple string representation. - preference.setSummary(stringValue); - } - return true; - } - }; - - /** - * Helper method to determine if the device has an extra-large screen. For - * example, 10" tablets are extra-large. - */ - private static boolean isXLargeTablet(Context context) { - return (context.getResources().getConfiguration().screenLayout - & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_XLARGE; - } - - /** - * Binds a preference's summary to its value. More specifically, when the - * preference's value is changed, its summary (line of text below the - * preference title) is updated to reflect the value. The summary is also - * immediately updated upon calling this method. The exact display format is - * dependent on the type of preference. - * - * @see #sBindPreferenceSummaryToValueListener - */ - private static void bindPreferenceSummaryToValue(Preference preference) { - // Set the listener to watch for value changes. - preference.setOnPreferenceChangeListener(sBindPreferenceSummaryToValueListener); - - // Trigger the listener immediately with the preference's - // current value. - sBindPreferenceSummaryToValueListener.onPreferenceChange(preference, - PreferenceManager - .getDefaultSharedPreferences(preference.getContext()) - .getAll().get(preference.getKey())); - } - @Override public int getAppTheme() { return AudioApplication.getTheme(this, R.style.RecThemeLight, R.style.RecThemeDark);