use of net.osmand.plus.helpers.TargetPointsHelper in project Osmand by osmandapp.
the class AddPointBottomSheetDialog method createSwitchStartAndEndItem.
private void createSwitchStartAndEndItem() {
final View switchStartAndEndView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.bottom_sheet_item_simple_56dp, null);
TextView title = (TextView) switchStartAndEndView.findViewById(R.id.title);
String start = getString(R.string.route_start_point);
String destination = getString(R.string.route_descr_destination);
String titleS = getString(R.string.swap_two_places, start, destination);
SpannableString titleSpan = new SpannableString(titleS);
int startIndex = titleS.indexOf(start);
int destinationIndex = titleS.indexOf(destination);
if (startIndex != -1 && destinationIndex != -1) {
Typeface typeface = FontCache.getRobotoMedium(getContext());
titleSpan.setSpan(new CustomTypefaceSpan(typeface), startIndex, startIndex + start.length(), 0);
titleSpan.setSpan(new CustomTypefaceSpan(typeface), destinationIndex, destinationIndex + destination.length(), 0);
}
title.setText(titleSpan);
BaseBottomSheetItem switchStartAndEndItem = new SimpleBottomSheetItem.Builder().setIcon(getContentIcon(R.drawable.ic_action_change_navigation_points)).setCustomView(switchStartAndEndView).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
MapActivity mapActivity = (MapActivity) getActivity();
if (mapActivity != null) {
TargetPointsHelper targetsHelper = mapActivity.getMyApplication().getTargetPointsHelper();
TargetPoint startPoint = targetsHelper.getPointToStart();
if (startPoint == null) {
mapActivity.getMyApplication().showShortToastMessage(R.string.route_add_start_point);
return;
}
WaypointDialogHelper.switchStartAndFinish(mapActivity.getMyApplication(), mapActivity, mapActivity.getDashboard().getWaypointDialogHelper(), true);
}
dismiss();
}
}).create();
items.add(switchStartAndEndItem);
}
use of net.osmand.plus.helpers.TargetPointsHelper in project Osmand by osmandapp.
the class MapActions method setGPXRouteParams.
public void setGPXRouteParams(GPXFile result) {
if (result == null) {
app.getRoutingHelper().setGpxParams(null);
settings.FOLLOW_THE_GPX_ROUTE.set(null);
} else {
GPXRouteParams.GPXRouteParamsBuilder params = new GPXRouteParams.GPXRouteParamsBuilder(result, settings);
params.setCalculateOsmAndRouteParts(settings.GPX_ROUTE_CALC_OSMAND_PARTS.get());
params.setCalculateOsmAndRoute(settings.GPX_ROUTE_CALC.get());
params.setSelectedSegment(settings.GPX_ROUTE_SEGMENT.get());
List<Location> ps = params.getPoints(settings.getContext());
app.getRoutingHelper().setGpxParams(params);
settings.FOLLOW_THE_GPX_ROUTE.set(result.path);
if (!ps.isEmpty()) {
Location startLoc = ps.get(0);
Location finishLoc = ps.get(ps.size() - 1);
Location location = app.getLocationProvider().getLastKnownLocation();
TargetPointsHelper pointsHelper = app.getTargetPointsHelper();
pointsHelper.clearAllIntermediatePoints(false);
if (location == null || MapUtils.getDistance(location, startLoc) <= START_TRACK_POINT_MY_LOCATION_RADIUS_METERS) {
pointsHelper.clearStartPoint(false);
} else {
pointsHelper.setStartPoint(new LatLon(startLoc.getLatitude(), startLoc.getLongitude()), false, null);
}
pointsHelper.navigateToPoint(new LatLon(finishLoc.getLatitude(), finishLoc.getLongitude()), false, -1);
}
}
}
Aggregations