use of net.osmand.plus.quickaction.actions.SwitchProfileAction in project Osmand by osmandapp.
the class SelectMapViewQuickActionsBottomSheet method populateItemsList.
private void populateItemsList() {
Context context = getContext();
if (context == null) {
return;
}
int counter = 0;
if (action instanceof MapStyleAction) {
MapStyleAction mapStyleAction = (MapStyleAction) action;
List<String> stylesList = mapStyleAction.getFilteredStyles();
for (String entry : stylesList) {
boolean selected = entry.equals(selectedItem);
createItemRow(selected, counter, getContentIcon(action.getIconRes()), mapStyleAction.getTranslatedItemName(context, entry), entry);
counter++;
}
} else if (action instanceof SwitchProfileAction) {
SwitchProfileAction switchProfileAction = (SwitchProfileAction) action;
List<String> profilesKeys = (List<String>) switchProfileAction.loadListFromParams();
for (String key : profilesKeys) {
ApplicationMode appMode = ApplicationMode.valueOfStringKey(key, null);
if (appMode != null) {
boolean selected = key.equals(selectedItem);
int iconId = appMode.getIconRes();
int color = appMode.getProfileColor(nightMode);
Drawable icon = getPaintedIcon(iconId, color);
String translatedName = appMode.toHumanString();
createItemRow(selected, counter, icon, translatedName, key);
counter++;
}
}
} else if (action instanceof SwitchableAction) {
SwitchableAction switchableAction = (SwitchableAction) action;
List<Pair<String, String>> sources = (List<Pair<String, String>>) switchableAction.loadListFromParams();
for (Pair<String, String> entry : sources) {
String tag = entry.first;
boolean selected = tag.equals(selectedItem);
createItemRow(selected, counter, getContentIcon(action.getIconRes()), entry.second, tag);
counter++;
}
}
}
Aggregations