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
public boolean onPreferenceChange(Preference preference, Object newValue) {
String key = preference.getKey();
ApplicationMode applicationMode = getAppMode(key);
ApplicationMode applicationMode = ApplicationMode.valueOfStringKey(preference.getKey(), null);
if (applicationMode != null) {
if (newValue instanceof Boolean) {
boolean isChecked = (Boolean) newValue;
@ -91,15 +90,6 @@ public class MainSettingsFragment extends BaseSettingsFragment {
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() {
ApplicationMode selectedMode = app.getSettings().APPLICATION_MODE.get();
String title = selectedMode.toHumanString(getContext());