Fix saving gpx at plan route

This commit is contained in:
max-klaus 2020-08-26 15:13:51 +03:00
parent da4c08c05d
commit ffde5da67a
3 changed files with 21 additions and 13 deletions

View file

@ -596,10 +596,10 @@ public class MeasurementEditingContext {
@Override
public void updateProgress(int progress) {
int pairs = calculatedPairs + pointsToCalculateSize;
int pairs = pointsToCalculateSize;
if (pairs != 0) {
int pairProgress = 100 / pairs;
progress = calculatedPairs * pairProgress + progress / pairs;
float pairProgress = 100f / pairs;
progress = (int)(calculatedPairs * pairProgress + (float) progress / pairs);
}
progressListener.updateProgress(progress);
}
@ -633,6 +633,7 @@ public class MeasurementEditingContext {
pts.add(pt);
}
calculatedPairs++;
params.calculationProgressCallback.updateProgress(0);
List<RouteSegmentResult> originalRoute = route.getOriginalRoute();
if (Algorithms.isEmpty(originalRoute)) {
originalRoute = Collections.singletonList(routePlannerFrontEnd.generateStraightLineSegment(

View file

@ -472,13 +472,6 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
displaySegmentPoints();
}
}
/*
if (saved == null) {
saved = gpxData != null
&& (gpxData.getActionType() == ActionType.ADD_ROUTE_POINTS
|| gpxData.getActionType() == ActionType.EDIT_SEGMENT);
}
*/
}
}
@ -1443,6 +1436,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
private ProgressDialog progressDialog;
private File toSave;
private GPXFile savedGpxFile;
@Override
protected void onPreExecute() {
@ -1494,6 +1488,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
}
Exception res = GPXUtilities.writeGpxFile(toSave, gpx);
gpx.path = toSave.getAbsolutePath();
savedGpxFile = gpx;
if (showOnMap) {
app.getSelectedGpxHelper().selectGpxFile(gpx, true, false);
}
@ -1564,6 +1559,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
}
}
Exception res = GPXUtilities.writeGpxFile(toSave, gpx);
savedGpxFile = gpx;
if (showOnMap) {
SelectedGpxFile sf = app.getSelectedGpxHelper().selectGpxFile(gpx, true, false);
if (sf != null) {
@ -1592,6 +1588,13 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
mapActivity.refreshMap();
if (warning == null) {
editingCtx.setChangesSaved();
if (editingCtx.isNewData() && savedGpxFile != null) {
QuadRect rect = savedGpxFile.getRect();
TrkSegment segment = savedGpxFile.getNonEmptyTrkSegment();
GpxData gpxData = new GpxData(savedGpxFile, rect, ActionType.EDIT_SEGMENT, segment);
editingCtx.setGpxData(gpxData);
updateToolbar();
}
if (isInEditMode()) {
dismiss(mapActivity);
} else {
@ -1605,7 +1608,12 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
public void onClick(View view) {
MapActivity mapActivity = mapActivityRef.get();
if (AndroidUtils.isActivityNotDestroyed(mapActivity)) {
FileUtils.renameFile(mapActivity, toSave, null);
FileUtils.renameFile(mapActivity, toSave, new FileUtils.RenameCallback() {
@Override
public void renamedTo(File file) {
}
});
}
}
});

View file

@ -1263,13 +1263,12 @@ public class RoutingHelper {
public void run() {
RouteCalculationProgress calculationProgress = params.calculationProgress;
if (isRouteBeingCalculated()) {
float pr = calculationProgress.getLinearProgress();
progressRoute.updateProgress((int) pr);
Thread t = currentRunningJob;
if(t instanceof RouteRecalculationThread && ((RouteRecalculationThread) t).params != params) {
// different calculation started
return;
} else {
progressRoute.updateProgress((int) calculationProgress.getLinearProgress());
if (calculationProgress.requestPrivateAccessRouting) {
progressRoute.requestPrivateAccessRouting();
}