Search in sources :

Example 46 with PointDescription

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

the class AvoidSpecificRoads method showOnMap.

private void showOnMap(MapActivity ctx, double lat, double lon, String name, DialogInterface dialog) {
    AnimateDraggingMapThread thread = ctx.getMapView().getAnimatedDraggingThread();
    int fZoom = ctx.getMapView().getZoom() < 15 ? 15 : ctx.getMapView().getZoom();
    if (thread.isAnimating()) {
        ctx.getMapView().setIntZoom(fZoom);
        ctx.getMapView().setLatLon(lat, lon);
    } else {
        thread.startMoving(lat, lon, fZoom, true);
    }
    ctx.getContextMenu().show(new LatLon(lat, lon), new PointDescription("", name), null);
    dialog.dismiss();
}
Also used : LatLon(net.osmand.data.LatLon) AnimateDraggingMapThread(net.osmand.plus.views.AnimateDraggingMapThread) PointDescription(net.osmand.data.PointDescription)

Example 47 with PointDescription

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

the class AddWaypointBottomSheetDialogFragment method createMenuItems.

@Override
public void createMenuItems(Bundle savedInstanceState) {
    Bundle args = getArguments();
    final LatLon latLon = new LatLon(args.getDouble(LAT_KEY), args.getDouble(LON_KEY));
    final PointDescription name = PointDescription.deserializeFromString(args.getString(POINT_DESCRIPTION_KEY), latLon);
    final TargetPointsHelper targetPointsHelper = getMyApplication().getTargetPointsHelper();
    items.add(new TitleItem(getString(R.string.new_destination_point_dialog)));
    BaseBottomSheetItem replaceDestItem = new BottomSheetItemWithDescription.Builder().setDescription(getCurrentPointName(targetPointsHelper.getPointToNavigate(), false)).setDescriptionColorId(R.color.searchbar_text_hint_light).setIcon(getIcon(R.drawable.list_destination, 0)).setTitle(getString(R.string.replace_destination_point)).setLayoutId(R.layout.bottom_sheet_item_with_descr_56dp).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            targetPointsHelper.navigateToPoint(latLon, true, -1, name);
            dismiss();
        }
    }).create();
    items.add(replaceDestItem);
    BaseBottomSheetItem replaceStartItem = new BottomSheetItemWithDescription.Builder().setDescription(getCurrentPointName(targetPointsHelper.getPointToStart(), true)).setDescriptionColorId(R.color.searchbar_text_hint_light).setIcon(getIcon(R.drawable.list_startpoint, 0)).setTitle(getString(R.string.make_as_start_point)).setLayoutId(R.layout.bottom_sheet_item_with_descr_56dp).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            TargetPoint start = targetPointsHelper.getPointToStart();
            if (start != null) {
                targetPointsHelper.navigateToPoint(new LatLon(start.getLatitude(), start.getLongitude()), false, 0, start.getOriginalPointDescription());
            }
            targetPointsHelper.setStartPoint(latLon, true, name);
            dismiss();
        }
    }).create();
    items.add(replaceStartItem);
    items.add(new DividerHalfItem(getContext(), getBottomDividerColorId()));
    BaseBottomSheetItem subsequentDestItem = new BottomSheetItemWithDescription.Builder().setDescription(getString(R.string.subsequent_dest_description)).setDescriptionColorId(R.color.searchbar_text_hint_light).setIcon(getSubsequentDestIcon()).setTitle(getString(R.string.keep_and_add_destination_point)).setLayoutId(R.layout.bottom_sheet_item_with_descr_56dp).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            targetPointsHelper.navigateToPoint(latLon, true, targetPointsHelper.getIntermediatePoints().size() + 1, name);
            dismiss();
        }
    }).create();
    items.add(subsequentDestItem);
    BaseBottomSheetItem firstIntermItem = new BottomSheetItemWithDescription.Builder().setDescription(getString(R.string.first_intermediate_dest_description)).setDescriptionColorId(R.color.searchbar_text_hint_light).setIcon(getFirstIntermDestIcon()).setTitle(getString(R.string.add_as_first_destination_point)).setLayoutId(R.layout.bottom_sheet_item_with_descr_56dp).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            targetPointsHelper.navigateToPoint(latLon, true, 0, name);
            dismiss();
        }
    }).create();
    items.add(firstIntermItem);
    BaseBottomSheetItem lastIntermItem = new BottomSheetItemWithDescription.Builder().setDescription(getString(R.string.last_intermediate_dest_description)).setDescriptionColorId(R.color.searchbar_text_hint_light).setIcon(getLastIntermDistIcon()).setTitle(getString(R.string.add_as_last_destination_point)).setLayoutId(R.layout.bottom_sheet_item_with_descr_56dp).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            targetPointsHelper.navigateToPoint(latLon, true, targetPointsHelper.getIntermediatePoints().size(), name);
            dismiss();
        }
    }).create();
    items.add(lastIntermItem);
}
Also used : BaseBottomSheetItem(net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem) LatLon(net.osmand.data.LatLon) Bundle(android.os.Bundle) PointDescription(net.osmand.data.PointDescription) DividerHalfItem(net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerHalfItem) TitleItem(net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem) TargetPoint(net.osmand.plus.TargetPointsHelper.TargetPoint) TargetPointsHelper(net.osmand.plus.TargetPointsHelper) View(android.view.View) BottomSheetItemWithDescription(net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithDescription)

Example 48 with PointDescription

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

the class MapContextMenuFragment method createTransportStopRouteAdapter.

private TransportStopRouteAdapter createTransportStopRouteAdapter(List<TransportStopRoute> routes) {
    final TransportStopRouteAdapter adapter = new TransportStopRouteAdapter(getMyApplication(), routes, nightMode);
    adapter.setListener(new TransportStopRouteAdapter.OnClickListener() {

        @Override
        public void onClick(int position) {
            TransportStopRoute route = adapter.getItem(position);
            if (route != null) {
                PointDescription pd = new PointDescription(PointDescription.POINT_TYPE_TRANSPORT_ROUTE, route.getDescription(getMapActivity().getMyApplication(), false));
                menu.show(menu.getLatLon(), pd, route);
                TransportStopsLayer stopsLayer = getMapActivity().getMapLayers().getTransportStopsLayer();
                stopsLayer.setRoute(route);
                int cz = route.calculateZoom(0, getMapActivity().getMapView().getCurrentRotatedTileBox());
                getMapActivity().changeZoom(cz - getMapActivity().getMapView().getZoom());
            }
        }
    });
    return adapter;
}
Also used : TransportStopRoute(net.osmand.plus.transport.TransportStopRoute) PointDescription(net.osmand.data.PointDescription) QuadPoint(net.osmand.data.QuadPoint) TransportStopsLayer(net.osmand.plus.views.TransportStopsLayer)

Example 49 with PointDescription

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

the class ShowRouteInfoDialogFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final OsmandApplication app = getMyApplication();
    helper = app.getRoutingHelper();
    view = inflater.inflate(R.layout.route_info_layout, container, false);
    Toolbar toolbar = (Toolbar) view.findViewById(R.id.toolbar);
    toolbar.setNavigationIcon(getMyApplication().getIconsCache().getThemedIcon(R.drawable.ic_arrow_back));
    toolbar.setNavigationContentDescription(R.string.shared_string_close);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            dismiss();
        }
    });
    ((ImageView) view.findViewById(R.id.distance_icon)).setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_action_route_distance));
    ((ImageView) view.findViewById(R.id.time_icon)).setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_action_time_span));
    buildMenuButtons();
    listView = (ListView) view.findViewById(android.R.id.list);
    listView.setBackgroundColor(getResources().getColor(app.getSettings().isLightContent() ? R.color.ctx_menu_info_view_bg_light : R.color.ctx_menu_info_view_bg_dark));
    View topShadowView = inflater.inflate(R.layout.list_shadow_header, listView, false);
    listView.addHeaderView(topShadowView, null, false);
    View bottomShadowView = inflater.inflate(R.layout.list_shadow_footer, listView, false);
    listView.addFooterView(bottomShadowView, null, false);
    adapter = new RouteInfoAdapter(helper.getRouteDirections());
    listView.setAdapter(adapter);
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (position < 2) {
                return;
            }
            RouteDirectionInfo item = adapter.getItem(position - 2);
            Location loc = helper.getLocationFromRouteDirection(item);
            if (loc != null) {
                MapRouteInfoMenu.directionInfo = position - 2;
                OsmandSettings settings = getMyApplication().getSettings();
                settings.setMapLocationToShow(loc.getLatitude(), loc.getLongitude(), Math.max(13, settings.getLastKnownMapZoom()), new PointDescription(PointDescription.POINT_TYPE_MARKER, item.getDescriptionRoutePart() + " " + getTimeDescription(item)), false, null);
                MapActivity.launchMapActivityMoveToTop(getActivity());
                dismiss();
            }
        }
    });
    int dist = helper.getLeftDistance();
    int time = helper.getLeftTime();
    int hours = time / (60 * 60);
    int minutes = (time / 60) % 60;
    ((TextView) view.findViewById(R.id.distance)).setText(OsmAndFormatter.getFormattedDistance(dist, app));
    StringBuilder timeStr = new StringBuilder();
    if (hours > 0) {
        timeStr.append(hours).append(" ").append(getString(R.string.osmand_parking_hour)).append(" ");
    }
    if (minutes > 0) {
        timeStr.append(minutes).append(" ").append(getString(R.string.osmand_parking_minute));
    }
    ((TextView) view.findViewById(R.id.time)).setText(timeStr);
    view.findViewById(R.id.go_button).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            MapActivity activity = (MapActivity) getActivity();
            if (activity != null) {
                activity.getMapLayers().getMapControlsLayer().startNavigation();
                dismiss();
            }
        }
    });
    makeGpx();
    if (hasHeights) {
        View headerView = inflater.inflate(R.layout.route_info_header, null);
        buildHeader(headerView);
        listView.addHeaderView(headerView);
    }
    return view;
}
Also used : OsmandApplication(net.osmand.plus.OsmandApplication) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) OsmandSettings(net.osmand.plus.OsmandSettings) PointDescription(net.osmand.data.PointDescription) RouteDirectionInfo(net.osmand.plus.routing.RouteDirectionInfo) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ImageView(android.widget.ImageView) Toolbar(android.support.v7.widget.Toolbar) Location(net.osmand.Location)

Example 50 with PointDescription

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

the class ShowRouteInfoDialogFragment method openDetails.

void openDetails() {
    if (gpxItem != null) {
        LatLon location = null;
        WptPt wpt = null;
        gpxItem.chartTypes = new GPXDataSetType[] { GPXDataSetType.ALTITUDE, GPXDataSetType.SLOPE };
        if (gpxItem.chartHighlightPos != -1) {
            TrkSegment segment = gpx.tracks.get(0).segments.get(0);
            if (segment != null) {
                float distance = gpxItem.chartHighlightPos * elevationDataSet.getDivX();
                for (WptPt p : segment.points) {
                    if (p.distance >= distance) {
                        wpt = p;
                        break;
                    }
                }
                if (wpt != null) {
                    location = new LatLon(wpt.lat, wpt.lon);
                }
            }
        }
        if (location == null) {
            location = new LatLon(gpxItem.locationStart.lat, gpxItem.locationStart.lon);
        }
        if (wpt != null) {
            gpxItem.locationOnMap = wpt;
        } else {
            gpxItem.locationOnMap = gpxItem.locationStart;
        }
        final MapActivity activity = (MapActivity) getActivity();
        if (activity != null) {
            dismiss();
            final OsmandSettings settings = activity.getMyApplication().getSettings();
            settings.setMapLocationToShow(location.getLatitude(), location.getLongitude(), settings.getLastKnownMapZoom(), new PointDescription(PointDescription.POINT_TYPE_WPT, gpxItem.name), false, gpxItem);
            final MapRouteInfoMenu mapRouteInfoMenu = activity.getMapLayers().getMapControlsLayer().getMapRouteInfoMenu();
            if (MapRouteInfoMenu.isVisible()) {
                // We arrived here by the route info menu.
                // First, we close it and then show the details.
                mapRouteInfoMenu.setOnDismissListener(new OnDismissListener() {

                    @Override
                    public void onDismiss(DialogInterface dialog) {
                        mapRouteInfoMenu.setOnDismissListener(null);
                        MapActivity.launchMapActivityMoveToTop(activity);
                    }
                });
                mapRouteInfoMenu.hide();
            } else {
                // We arrived here by the dashboard.
                MapActivity.launchMapActivityMoveToTop(activity);
            }
        }
    }
}
Also used : LatLon(net.osmand.data.LatLon) WptPt(net.osmand.plus.GPXUtilities.WptPt) MapRouteInfoMenu(net.osmand.plus.mapcontextmenu.other.MapRouteInfoMenu) DialogInterface(android.content.DialogInterface) PointDescription(net.osmand.data.PointDescription) OnDismissListener(android.content.DialogInterface.OnDismissListener) TrkSegment(net.osmand.plus.GPXUtilities.TrkSegment) OsmandSettings(net.osmand.plus.OsmandSettings)

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