diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementEditingContext.java b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementEditingContext.java index 941c680502..32b469db06 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementEditingContext.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementEditingContext.java @@ -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 originalRoute = route.getOriginalRoute(); if (Algorithms.isEmpty(originalRoute)) { originalRoute = Collections.singletonList(routePlannerFrontEnd.generateStraightLineSegment( diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java index 2600534195..736ed66d50 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java @@ -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) { + + } + }); } } }); diff --git a/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java b/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java index 9a29bd355d..57becfe9a6 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java +++ b/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java @@ -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(); }