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();
}
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);
}
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;
}
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;
}
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);
}
}
}
}
Aggregations