Search in sources :

Example 6 with BackgroundType

use of net.osmand.data.FavouritePoint.BackgroundType in project Osmand by osmandapp.

the class ContextMenuLayer method selectObjectsForContextMenu.

@NonNull
private Map<Object, IContextMenuProvider> selectObjectsForContextMenu(RotatedTileBox tileBox, PointF point, boolean acquireObjLatLon, boolean unknownLocation) {
    Map<LatLon, BackgroundType> pressedLatLonFull = new HashMap<>();
    Map<LatLon, BackgroundType> pressedLatLonSmall = new HashMap<>();
    Map<Object, IContextMenuProvider> selectedObjects = new HashMap<>();
    List<Object> s = new ArrayList<>();
    for (OsmandMapLayer lt : view.getLayers()) {
        if (lt instanceof IContextMenuProvider) {
            s.clear();
            final IContextMenuProvider l = (IContextMenuProvider) lt;
            l.collectObjectsFromPoint(point, tileBox, s, unknownLocation);
            for (Object o : s) {
                selectedObjects.put(o, l);
                if (acquireObjLatLon && l.isObjectClickable(o)) {
                    LatLon latLon = l.getObjectLocation(o);
                    BackgroundType backgroundType = DEFAULT_BACKGROUND_TYPE;
                    if (o instanceof OsmBugsLayer.OpenStreetNote) {
                        backgroundType = BackgroundType.COMMENT;
                    }
                    if (o instanceof FavouritePoint) {
                        backgroundType = ((FavouritePoint) o).getBackgroundType();
                    }
                    if (o instanceof GPXUtilities.WptPt) {
                        backgroundType = BackgroundType.getByTypeName(((GPXUtilities.WptPt) o).getBackgroundType(), DEFAULT_BACKGROUND_TYPE);
                    }
                    if (lt.isPresentInFullObjects(latLon) && !pressedLatLonFull.containsKey(latLon)) {
                        pressedLatLonFull.put(latLon, backgroundType);
                    } else if (lt.isPresentInSmallObjects(latLon) && !pressedLatLonSmall.containsKey(latLon)) {
                        pressedLatLonSmall.put(latLon, backgroundType);
                    }
                }
            }
        }
    }
    if (acquireObjLatLon) {
        this.pressedLatLonFull = pressedLatLonFull;
        this.pressedLatLonSmall = pressedLatLonSmall;
    }
    return selectedObjects;
}
Also used : WptPt(net.osmand.GPXUtilities.WptPt) FavouritePoint(net.osmand.data.FavouritePoint) HashMap(java.util.HashMap) TIntArrayList(gnu.trove.list.array.TIntArrayList) ArrayList(java.util.ArrayList) LatLon(net.osmand.data.LatLon) BackgroundType(net.osmand.data.FavouritePoint.BackgroundType) OsmandMapLayer(net.osmand.plus.views.layers.base.OsmandMapLayer) ObfMapObject(net.osmand.core.jni.ObfMapObject) CallbackWithObject(net.osmand.CallbackWithObject) RenderedObject(net.osmand.NativeLibrary.RenderedObject) MapObject(net.osmand.core.jni.MapObject) NonNull(androidx.annotation.NonNull)

Aggregations

BackgroundType (net.osmand.data.FavouritePoint.BackgroundType)6 LatLon (net.osmand.data.LatLon)3 TIntArrayList (gnu.trove.list.array.TIntArrayList)2 ArrayList (java.util.ArrayList)2 RenderedObject (net.osmand.NativeLibrary.RenderedObject)2 FavouritePoint (net.osmand.data.FavouritePoint)2 OsmNotesPoint (net.osmand.plus.plugins.osmedit.data.OsmNotesPoint)2 OsmPoint (net.osmand.plus.plugins.osmedit.data.OsmPoint)2 PointImageDrawable (net.osmand.plus.views.PointImageDrawable)2 Bitmap (android.graphics.Bitmap)1 Paint (android.graphics.Paint)1 Rect (android.graphics.Rect)1 LayoutInflater (android.view.LayoutInflater)1 TextView (android.widget.TextView)1 NonNull (androidx.annotation.NonNull)1 HashMap (java.util.HashMap)1 CallbackWithObject (net.osmand.CallbackWithObject)1 WptPt (net.osmand.GPXUtilities.WptPt)1 AidlMapPointWrapper (net.osmand.aidl.AidlMapPointWrapper)1 MapObject (net.osmand.core.jni.MapObject)1