use of net.osmand.plus.views.ContextMenuLayer.IContextMenuProvider in project Osmand by osmandapp.
the class MapMultiSelectionMenu method createCollection.
private void createCollection(Map<Object, IContextMenuProvider> selectedObjects) {
this.selectedObjects.clear();
this.selectedObjects.putAll(selectedObjects);
objects.clear();
for (Map.Entry<Object, IContextMenuProvider> e : selectedObjects.entrySet()) {
Object selectedObj = e.getKey();
IContextMenuProvider contextObject = selectedObjects.get(selectedObj);
LatLon ll = null;
PointDescription pointDescription = null;
if (contextObject != null) {
ll = contextObject.getObjectLocation(selectedObj);
pointDescription = contextObject.getObjectName(selectedObj);
}
if (ll == null) {
ll = latLon;
}
if (pointDescription == null) {
pointDescription = new PointDescription(latLon.getLatitude(), latLon.getLongitude());
}
MenuObject menuObject = new MenuObject(ll, pointDescription, selectedObj, getMapActivity());
objects.add(menuObject);
if (contextObject instanceof ContextMenuLayer.IContextMenuProviderSelection) {
menuObject.order = ((ContextMenuLayer.IContextMenuProviderSelection) contextObject).getOrder(selectedObj);
}
}
Collections.sort(objects, new Comparator<MenuObject>() {
@Override
public int compare(MenuObject obj1, MenuObject obj2) {
if (obj1.order == obj2.order) {
return obj1.getTitleStr().compareToIgnoreCase(obj2.getTitleStr());
} else {
return obj1.order - obj2.order;
}
}
});
}
use of net.osmand.plus.views.ContextMenuLayer.IContextMenuProvider in project Osmand by osmandapp.
the class MapMultiSelectionMenu method openContextMenu.
public void openContextMenu(@NonNull MenuObject menuObject) {
IContextMenuProvider provider = selectedObjects.remove(menuObject.getObject());
hide();
ContextMenuLayer contextMenuLayer = getMapActivity().getMapLayers().getContextMenuLayer();
contextMenuLayer.showContextMenu(menuObject.getLatLon(), menuObject.getPointDescription(), menuObject.getObject(), provider);
}
Aggregations