use of net.osmand.plus.routing.GPXRouteParams.GPXRouteParamsBuilder in project Osmand by osmandapp.
the class RoutePreferencesMenu method updateSpinnerItems.
private void updateSpinnerItems(final TextView gpxSpinner) {
GPXRouteParamsBuilder rp = mapActivity.getRoutingHelper().getCurrentGPXRoute();
gpxSpinner.setText(rp == null ? mapActivity.getString(R.string.shared_string_none) : new File(rp.getFile().path).getName());
}
use of net.osmand.plus.routing.GPXRouteParams.GPXRouteParamsBuilder in project Osmand by osmandapp.
the class RoutePreferencesMenu method showOptionsMenu.
private void showOptionsMenu(final TextView gpxSpinner) {
GPXRouteParamsBuilder rp = mapActivity.getRoutingHelper().getCurrentGPXRoute();
final PopupMenu optionsMenu = new PopupMenu(gpxSpinner.getContext(), gpxSpinner);
MenuItem item = optionsMenu.getMenu().add(mapActivity.getString(R.string.shared_string_none));
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
if (mapActivity.getRoutingHelper().getCurrentGPXRoute() != null) {
mapActivity.getRoutingHelper().setGpxParams(null);
settings.FOLLOW_THE_GPX_ROUTE.set(null);
mapActivity.getRoutingHelper().onSettingsChanged(true);
}
updateParameters();
return true;
}
});
item = optionsMenu.getMenu().add(mapActivity.getString(R.string.select_gpx));
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
openGPXFileSelection(gpxSpinner);
return true;
}
});
if (rp != null) {
item = optionsMenu.getMenu().add(new File(rp.getFile().path).getName());
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
// nothing to change
return true;
}
});
}
optionsMenu.show();
}
use of net.osmand.plus.routing.GPXRouteParams.GPXRouteParamsBuilder in project Osmand by osmandapp.
the class FollowTrackFragment method onSegmentSelect.
@Override
public void onSegmentSelect(@NonNull GPXFile gpxFile, int selectedSegment) {
app.getSettings().GPX_ROUTE_SEGMENT.set(selectedSegment);
selectTrackToFollow(gpxFile);
GPXRouteParamsBuilder paramsBuilder = app.getRoutingHelper().getCurrentGPXRoute();
if (paramsBuilder != null) {
paramsBuilder.setSelectedSegment(selectedSegment);
app.getRoutingHelper().onSettingsChanged(true);
}
updateSelectionMode(false);
}
use of net.osmand.plus.routing.GPXRouteParams.GPXRouteParamsBuilder in project Osmand by osmandapp.
the class MapRouteInfoMenu method isFinishPointFromTrack.
private boolean isFinishPointFromTrack() {
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
OsmandApplication app = mapActivity.getMyApplication();
GPXRouteParamsBuilder routeParams = app.getRoutingHelper().getCurrentGPXRoute();
if (routeParams != null) {
TargetPoint target = app.getTargetPointsHelper().getPointToNavigate();
if (target != null) {
List<Location> points = routeParams.getPoints(app);
if (!Algorithms.isEmpty(points)) {
Location loc = points.get(points.size() - 1);
LatLon latLon = new LatLon(loc.getLatitude(), loc.getLongitude());
LatLon targetLatLon = new LatLon(target.getLatitude(), target.getLongitude());
return latLon.equals(targetLatLon);
}
}
}
}
return false;
}
use of net.osmand.plus.routing.GPXRouteParams.GPXRouteParamsBuilder in project Osmand by osmandapp.
the class MapRouteInfoMenu method setupViaText.
private void setupViaText(View view) {
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
OsmandApplication app = mapActivity.getMyApplication();
TextView title = view.findViewById(R.id.ViaView);
TextView description = view.findViewById(R.id.ViaSubView);
TextView buttonDescription = view.findViewById(R.id.via_button_description);
String via = generateViaDescription();
GPXRouteParamsBuilder routeParamsBuilder = app.getRoutingHelper().getCurrentGPXRoute();
if (routeParamsBuilder != null) {
GPXFile gpxFile = routeParamsBuilder.getFile();
String fileName = null;
if (!Algorithms.isEmpty(gpxFile.path)) {
fileName = new File(gpxFile.path).getName();
} else if (!Algorithms.isEmpty(gpxFile.tracks)) {
fileName = gpxFile.tracks.get(0).name;
}
if (Algorithms.isEmpty(fileName)) {
fileName = app.getString(R.string.shared_string_gpx_track);
}
GPXRouteParamsBuilder routeParams = app.getRoutingHelper().getCurrentGPXRoute();
if (gpxFile.getNonEmptySegmentsCount() > 1 && routeParams != null && routeParams.getSelectedSegment() != -1) {
int selectedSegmentCount = routeParams.getSelectedSegment() + 1;
int totalSegmentCount = routeParams.getFile().getNonEmptyTrkSegments(false).size();
fileName = app.getString(R.string.of, selectedSegmentCount, totalSegmentCount) + ", " + fileName;
}
title.setText(GpxUiHelper.getGpxTitle(fileName));
description.setText(R.string.follow_track);
buttonDescription.setText(R.string.shared_string_add);
} else {
title.setText(via);
buttonDescription.setText(R.string.shared_string_edit);
description.setText(app.getString(R.string.intermediate_destinations) + " (" + app.getTargetPointsHelper().getIntermediatePoints().size() + ")");
}
}
}
Aggregations