Search in sources :

Example 41 with PointDescription

use of net.osmand.data.PointDescription 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;
            }
        }
    });
}
Also used : LatLon(net.osmand.data.LatLon) PointDescription(net.osmand.data.PointDescription) ContextMenuLayer(net.osmand.plus.views.ContextMenuLayer) HashMap(java.util.HashMap) Map(java.util.Map) IContextMenuProvider(net.osmand.plus.views.ContextMenuLayer.IContextMenuProvider)

Example 42 with PointDescription

use of net.osmand.data.PointDescription in project Osmand by osmandapp.

the class MapRouteInfoMenu method generateViaDescription.

public String generateViaDescription() {
    TargetPointsHelper targets = getTargets();
    List<TargetPoint> points = targets.getIntermediatePointsNavigation();
    if (points.size() == 0) {
        return "";
    }
    StringBuilder via = new StringBuilder();
    for (int i = 0; i < points.size(); i++) {
        if (i > 0) {
            via.append(" ");
        }
        TargetPoint p = points.get(i);
        String description = p.getOnlyName();
        via.append(getRoutePointDescription(p.point, description));
        boolean needAddress = new PointDescription(PointDescription.POINT_TYPE_LOCATION, description).isSearchingAddress(mapActivity) && !intermediateRequestsLatLon.contains(p.point);
        if (needAddress) {
            AddressLookupRequest lookupRequest = new AddressLookupRequest(p.point, new GeocodingLookupService.OnAddressLookupResult() {

                @Override
                public void geocodingDone(String address) {
                    updateMenu();
                }
            }, null);
            intermediateRequestsLatLon.add(p.point);
            geocodingLookupService.lookupAddress(lookupRequest);
        }
    }
    return via.toString();
}
Also used : GeocodingLookupService(net.osmand.plus.GeocodingLookupService) PointDescription(net.osmand.data.PointDescription) TargetPoint(net.osmand.plus.TargetPointsHelper.TargetPoint) TargetPointsHelper(net.osmand.plus.TargetPointsHelper) TargetPoint(net.osmand.plus.TargetPointsHelper.TargetPoint) AddressLookupRequest(net.osmand.plus.GeocodingLookupService.AddressLookupRequest)

Example 43 with PointDescription

use of net.osmand.data.PointDescription in project Osmand by osmandapp.

the class MapRouteInfoMenu method updateViaView.

private void updateViaView(final View parentView) {
    String via = generateViaDescription();
    View viaLayout = parentView.findViewById(R.id.ViaLayout);
    View viaLayoutDivider = parentView.findViewById(R.id.viaLayoutDivider);
    ImageView swapDirectionView = (ImageView) parentView.findViewById(R.id.swap_direction_image_view);
    if (via.length() == 0) {
        viaLayout.setVisibility(View.GONE);
        viaLayoutDivider.setVisibility(View.GONE);
        swapDirectionView.setVisibility(View.VISIBLE);
    } else {
        swapDirectionView.setVisibility(View.GONE);
        viaLayout.setVisibility(View.VISIBLE);
        viaLayoutDivider.setVisibility(View.VISIBLE);
        ((TextView) parentView.findViewById(R.id.ViaView)).setText(via);
    }
    viaLayout.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (getTargets().checkPointToNavigateShort()) {
                mapActivity.getMapActions().openIntermediatePointsDialog();
            }
        }
    });
    ImageView viaIcon = (ImageView) parentView.findViewById(R.id.viaIcon);
    viaIcon.setImageDrawable(getIconOrig(R.drawable.list_intermediate));
    swapDirectionView.setImageDrawable(mapActivity.getMyApplication().getIconsCache().getIcon(R.drawable.ic_action_change_navigation_points, isLight() ? R.color.route_info_control_icon_color_light : R.color.route_info_control_icon_color_dark));
    swapDirectionView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            TargetPointsHelper targetPointsHelper = getTargets();
            TargetPoint startPoint = targetPointsHelper.getPointToStart();
            TargetPoint endPoint = targetPointsHelper.getPointToNavigate();
            if (startPoint == null) {
                Location loc = mapActivity.getMyApplication().getLocationProvider().getLastKnownLocation();
                if (loc != null) {
                    startPoint = TargetPoint.createStartPoint(new LatLon(loc.getLatitude(), loc.getLongitude()), new PointDescription(PointDescription.POINT_TYPE_MY_LOCATION, mapActivity.getString(R.string.shared_string_my_location)));
                }
            }
            if (startPoint != null && endPoint != null) {
                targetPointsHelper.navigateToPoint(startPoint.point, false, -1, startPoint.getPointDescription(mapActivity));
                targetPointsHelper.setStartPoint(endPoint.point, false, endPoint.getPointDescription(mapActivity));
                targetPointsHelper.updateRouteAndRefresh(true);
                updateFromIcon();
                updateToIcon(parentView);
            }
        }
    });
}
Also used : LatLon(net.osmand.data.LatLon) PointDescription(net.osmand.data.PointDescription) TextView(android.widget.TextView) ImageView(android.widget.ImageView) TargetPoint(net.osmand.plus.TargetPointsHelper.TargetPoint) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) OsmandMapTileView(net.osmand.plus.views.OsmandMapTileView) TargetPointsHelper(net.osmand.plus.TargetPointsHelper) Location(net.osmand.Location)

Example 44 with PointDescription

use of net.osmand.data.PointDescription in project Osmand by osmandapp.

the class FavouritePointMenuBuilder method getCollapsableFavouritesView.

private CollapsableView getCollapsableFavouritesView(final Context context, boolean collapsed, @NonNull final FavoriteGroup group, FavouritePoint selectedPoint) {
    LinearLayout view = (LinearLayout) buildCollapsableContentView(context, collapsed, true);
    List<FavouritePoint> points = group.points;
    for (int i = 0; i < points.size() && i < 10; i++) {
        final FavouritePoint point = points.get(i);
        boolean selected = selectedPoint != null && selectedPoint.equals(point);
        TextViewEx button = buildButtonInCollapsableView(context, selected, false);
        String name = point.getName();
        button.setText(name);
        if (!selected) {
            button.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    LatLon latLon = new LatLon(point.getLatitude(), point.getLongitude());
                    PointDescription pointDescription = new PointDescription(PointDescription.POINT_TYPE_FAVORITE, point.getName());
                    mapActivity.getContextMenu().show(latLon, pointDescription, point);
                }
            });
        }
        view.addView(button);
    }
    if (points.size() > 10) {
        TextViewEx button = buildButtonInCollapsableView(context, false, true);
        button.setText(context.getString(R.string.shared_string_show_all));
        button.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                OsmAndAppCustomization appCustomization = app.getAppCustomization();
                final Intent intent = new Intent(context, appCustomization.getFavoritesActivity());
                intent.putExtra(FavoritesActivity.OPEN_FAVOURITES_TAB, true);
                intent.putExtra(FavoritesActivity.GROUP_NAME_TO_SHOW, group.name);
                intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
                context.startActivity(intent);
            }
        });
        view.addView(button);
    }
    return new CollapsableView(view, this, collapsed);
}
Also used : FavouritePoint(net.osmand.data.FavouritePoint) Intent(android.content.Intent) View(android.view.View) TextView(android.widget.TextView) FavouritePoint(net.osmand.data.FavouritePoint) LatLon(net.osmand.data.LatLon) TextViewEx(net.osmand.plus.widgets.TextViewEx) OsmAndAppCustomization(net.osmand.plus.OsmAndAppCustomization) PointDescription(net.osmand.data.PointDescription) LinearLayout(android.widget.LinearLayout)

Example 45 with PointDescription

use of net.osmand.data.PointDescription in project Osmand by osmandapp.

the class TransportRouteController method showTransportStop.

private void showTransportStop(TransportStop stop) {
    if (mapContextMenu != null) {
        transportRoute.stop = stop;
        transportRoute.refStop = stop;
        PointDescription pd = new PointDescription(PointDescription.POINT_TYPE_TRANSPORT_ROUTE, transportRoute.getDescription(getMapActivity().getMyApplication(), false));
        updateControllers();
        LatLon stopLocation = stop.getLocation();
        if (mapContextMenu.isVisible()) {
            mapContextMenu.updateMapCenter(stopLocation);
        } else {
            mapContextMenu.setMapCenter(stopLocation);
            mapContextMenu.setMapPosition(getMapActivity().getMapView().getMapPosition());
        }
        mapContextMenu.setCenterMarker(true);
        mapContextMenu.setMapZoom(15);
        mapContextMenu.showOrUpdate(stopLocation, pd, transportRoute);
    }
}
Also used : LatLon(net.osmand.data.LatLon) PointDescription(net.osmand.data.PointDescription)

Aggregations

PointDescription (net.osmand.data.PointDescription)72 LatLon (net.osmand.data.LatLon)44 View (android.view.View)16 ImageView (android.widget.ImageView)13 TextView (android.widget.TextView)13 ArrayList (java.util.ArrayList)13 TargetPoint (net.osmand.plus.TargetPointsHelper.TargetPoint)13 FavouritePoint (net.osmand.data.FavouritePoint)12 TargetPointsHelper (net.osmand.plus.TargetPointsHelper)11 OsmandApplication (net.osmand.plus.OsmandApplication)10 OsmandSettings (net.osmand.plus.OsmandSettings)10 MapMarker (net.osmand.plus.MapMarkersHelper.MapMarker)8 Amenity (net.osmand.data.Amenity)7 WptPt (net.osmand.plus.GPXUtilities.WptPt)7 RoutingHelper (net.osmand.plus.routing.RoutingHelper)7 Intent (android.content.Intent)6 Paint (android.graphics.Paint)6 LinearLayout (android.widget.LinearLayout)6 Location (net.osmand.Location)6 DialogInterface (android.content.DialogInterface)5