Small refactoring. Used existed method ApplicationMode.valueOfStringKey

This commit is contained in:
Dima-1 2019-12-02 10:59:21 +02:00
parent b29d720c54
commit d25c32404a

View file

@ -79,8 +79,7 @@ public class MainSettingsFragment extends BaseSettingsFragment {
@Override @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
String key = preference.getKey(); ApplicationMode applicationMode = ApplicationMode.valueOfStringKey(preference.getKey(), null);
ApplicationMode applicationMode = getAppMode(key);
if (applicationMode != null) { if (applicationMode != null) {
if (newValue instanceof Boolean) { if (newValue instanceof Boolean) {
boolean isChecked = (Boolean) newValue; boolean isChecked = (Boolean) newValue;
@ -91,15 +90,6 @@ public class MainSettingsFragment extends BaseSettingsFragment {
return super.onPreferenceChange(preference, newValue); return super.onPreferenceChange(preference, newValue);
} }
ApplicationMode getAppMode(String key) {
for (ApplicationMode applicationMode : allAppModes) {
if (applicationMode.getStringKey().equals(key)) {
return applicationMode;
}
}
return null;
}
private void setupConfigureProfilePref() { private void setupConfigureProfilePref() {
ApplicationMode selectedMode = app.getSettings().APPLICATION_MODE.get(); ApplicationMode selectedMode = app.getSettings().APPLICATION_MODE.get();
String title = selectedMode.toHumanString(getContext()); String title = selectedMode.toHumanString(getContext());