use of net.osmand.plus.settings.backend.preferences.BooleanPreference in project Osmand by osmandapp.
the class RouteParametersFragment method createRoutingBooleanMultiSelectPref.
private MultiSelectBooleanPreference createRoutingBooleanMultiSelectPref(String groupKey, String title, String descr, List<RoutingParameter> routingParameters) {
MultiSelectBooleanPreference multiSelectPref = new MultiSelectBooleanPreference(app);
multiSelectPref.setKey(groupKey);
multiSelectPref.setTitle(title);
multiSelectPref.setSummary(descr);
multiSelectPref.setDescription(descr);
multiSelectPref.setLayoutResource(R.layout.preference_with_descr);
multiSelectPref.setIcon(getRoutingPrefIcon(groupKey));
multiSelectPref.setIconSpaceReserved(true);
String[] entries = new String[routingParameters.size()];
String[] prefsIds = new String[routingParameters.size()];
Set<String> enabledPrefsIds = new HashSet<>();
ApplicationMode selectedMode = getSelectedAppMode();
for (int i = 0; i < routingParameters.size(); i++) {
RoutingParameter p = routingParameters.get(i);
BooleanPreference booleanRoutingPref = (BooleanPreference) settings.getCustomRoutingBooleanProperty(p.getId(), p.getDefaultBoolean());
entries[i] = AndroidUtils.getRoutingStringPropertyName(app, p.getId(), p.getName());
prefsIds[i] = booleanRoutingPref.getId();
if (booleanRoutingPref.getModeValue(selectedMode)) {
enabledPrefsIds.add(booleanRoutingPref.getId());
}
}
multiSelectPref.setEntries(entries);
multiSelectPref.setEntryValues(prefsIds);
multiSelectPref.setValues(enabledPrefsIds);
return multiSelectPref;
}
Aggregations