use of net.osmand.plus.ContextMenuItem.INVALID_ID in project Osmand by osmandapp.
the class ConfigureMapMenu method createRenderingProperty.
public static ContextMenuItem createRenderingProperty(ContextMenuAdapter adapter, MapActivity activity, @DrawableRes int icon, RenderingRuleProperty p, String id, boolean nightMode) {
OsmandApplication app = activity.getMyApplication();
if (p.isBoolean()) {
String name = AndroidUtils.getRenderingStringPropertyName(activity, p.getAttrName(), p.getName());
return createBooleanRenderingProperty(activity, p.getAttrName(), name, id, p, icon, nightMode, null);
} else {
final CommonPreference<String> pref = app.getSettings().getCustomRenderProperty(p.getAttrName());
String descr;
if (!Algorithms.isEmpty(pref.get())) {
descr = AndroidUtils.getRenderingStringPropertyValue(activity, pref.get());
} else {
descr = AndroidUtils.getRenderingStringPropertyValue(app, p.getDefaultValueDescription());
}
String propertyName = AndroidUtils.getRenderingStringPropertyName(app, p.getAttrName(), p.getName());
ItemBuilder builder = ContextMenuItem.createBuilder(propertyName).setId(id).setListener((ad, itemId, pos, isChecked, viewCoordinates) -> {
if (AndroidUtils.isActivityNotDestroyed(activity)) {
ConfigureMapDialogs.showRenderingPropertyDialog(activity, adapter, p, pref, pos, nightMode);
}
return false;
}).setDescription(descr).setItemDeleteAction(makeDeleteAction(pref)).setLayout(R.layout.list_item_single_line_descrition_narrow);
if (icon != INVALID_ID) {
builder.setIcon(icon);
}
return builder.createItem();
}
}
Aggregations