Fix plan a route file name and segment calculation

This commit is contained in:
Dima-1 2020-08-03 19:32:53 +03:00
parent c034f7deab
commit 5be444ab87
2 changed files with 17 additions and 44 deletions

View file

@ -137,9 +137,11 @@ public class MeasurementEditingContext {
void setSnapToRoadAppMode(ApplicationMode snapToRoadAppMode) { void setSnapToRoadAppMode(ApplicationMode snapToRoadAppMode) {
if (this.snapToRoadAppMode != null && snapToRoadAppMode != null if (this.snapToRoadAppMode != null && snapToRoadAppMode != null
&& !this.snapToRoadAppMode.getStringKey().equals(snapToRoadAppMode.getStringKey())) { && !this.snapToRoadAppMode.getStringKey().equals(snapToRoadAppMode.getStringKey())) {
if (calculationType == WHOLE_TRACK) {
snappedToRoadPoints.clear(); snappedToRoadPoints.clear();
updateCacheForSnapIfNeeded(true); updateCacheForSnapIfNeeded(true);
} }
}
this.snapToRoadAppMode = snapToRoadAppMode; this.snapToRoadAppMode = snapToRoadAppMode;
} }

View file

@ -1058,46 +1058,11 @@ public class MeasurementToolFragment extends BaseOsmAndFragment {
fragment.show(mapActivity.getSupportFragmentManager(), SaveAsNewTrackBottomSheetDialogFragment.TAG); fragment.show(mapActivity.getSupportFragmentManager(), SaveAsNewTrackBottomSheetDialogFragment.TAG);
} }
// private AlertDialog showAddToTrackDialog(final MapActivity mapActivity) {
//
// CallbackWithObject<GPXFile[]> callbackWithObject = new CallbackWithObject<GPXFile[]>() {
// @Override
// public boolean processResult(GPXFile[] result) {
// GPXFile gpxFile;
// if (result != null && result.length > 0) {
// gpxFile = result[0];
// SelectedGpxFile selectedGpxFile = mapActivity.getMyApplication().getSelectedGpxHelper().getSelectedFileByPath(gpxFile.path);
// boolean showOnMap = selectedGpxFile != null;
// saveExistingGpx(gpxFile, showOnMap, ActionType.ADD_SEGMENT, false);
// }
// return true;
// }
// };
//
// return GpxUiHelper.selectGPXFile(mapActivity, false, false, callbackWithObject, nightMode);
// }
private void showAddToTrackDialog(final MapActivity mapActivity) { private void showAddToTrackDialog(final MapActivity mapActivity) {
if (mapActivity != null) { if (mapActivity != null) {
SelectFileBottomSheet.showInstance(mapActivity.getSupportFragmentManager(), SelectFileBottomSheet.showInstance(mapActivity.getSupportFragmentManager(),
createAddToTrackFileListener(),ADD_TO_TRACK); createAddToTrackFileListener(),ADD_TO_TRACK);
} }
/*
CallbackWithObject<GPXFile[]> callbackWithObject = new CallbackWithObject<GPXFile[]>() {
@Override
public boolean processResult(GPXFile[] result) {
GPXFile gpxFile;
if (result != null && result.length > 0) {
gpxFile = result[0];
SelectedGpxFile selectedGpxFile = mapActivity.getMyApplication().getSelectedGpxHelper().getSelectedFileByPath(gpxFile.path);
boolean showOnMap = selectedGpxFile != null;
saveExistingGpx(gpxFile, showOnMap, ActionType.ADD_SEGMENT, false);
}
return true;
}
};
return GpxUiHelper.selectGPXFile(mapActivity, false, false, callbackWithObject, nightMode);*/
} }
private void applyMovePointMode() { private void applyMovePointMode() {
@ -1444,14 +1409,20 @@ public class MeasurementToolFragment extends BaseOsmAndFragment {
} }
private String getSuggestedName(File dir) { private String getSuggestedName(File dir) {
final String suggestedName = new SimpleDateFormat("yyyy-MM-dd_HH-mm_EEE", Locale.US).format(new Date()); NewGpxData newGpxData = editingCtx.getNewGpxData();
String displayedName = suggestedName; String displayedName;
if (newGpxData == null) {
final String suggestedName = new SimpleDateFormat("EEE dd MMM yyyy", Locale.US).format(new Date());
displayedName = suggestedName;
File fout = new File(dir, suggestedName + GPX_FILE_EXT); File fout = new File(dir, suggestedName + GPX_FILE_EXT);
int ind = 1; int ind = 0;
while (fout.exists()) { while (fout.exists()) {
displayedName = suggestedName + "_" + (++ind); displayedName = suggestedName + "_" + (++ind);
fout = new File(dir, displayedName + GPX_FILE_EXT); fout = new File(dir, displayedName + GPX_FILE_EXT);
} }
} else {
displayedName = AndroidUtils.trimExtension(new File(newGpxData.getGpxFile().path).getName());
}
return displayedName; return displayedName;
} }