Fix exiting dialog

This commit is contained in:
PavelRatushny 2017-08-30 14:14:07 +03:00
parent d3a3d51a24
commit 56d40a6804

View file

@ -1410,21 +1410,25 @@ public class MeasurementToolFragment extends Fragment {
builder.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
final String name = new SimpleDateFormat("yyyy-MM-dd_HH-mm_EEE", Locale.US).format(new Date());
String fileName = name + GPX_SUFFIX;
File fout = new File(dir, fileName);
int ind = 1;
while (fout.exists()) {
fileName = name + "_" + (++ind) + GPX_SUFFIX;
fout = new File(dir, fileName);
}
SaveType saveType;
if (editingCtx.isInSnapToRoadMode()) {
saveType = SaveType.SNAP_TO_ROAD;
if (showOnMapToggle.isChecked()) {
final String name = new SimpleDateFormat("yyyy-MM-dd_HH-mm_EEE", Locale.US).format(new Date());
String fileName = name + GPX_SUFFIX;
File fout = new File(dir, fileName);
int ind = 1;
while (fout.exists()) {
fileName = name + "_" + (++ind) + GPX_SUFFIX;
fout = new File(dir, fileName);
}
SaveType saveType;
if (editingCtx.isInSnapToRoadMode()) {
saveType = SaveType.SNAP_TO_ROAD;
} else {
saveType = SaveType.LINE;
}
saveNewGpx(dir, fileName, true, saveType, true);
} else {
saveType = SaveType.LINE;
dismiss(mapActivity);
}
saveNewGpx(dir, fileName, showOnMapToggle.isChecked(), saveType, true);
}
});
} else {
@ -1441,12 +1445,7 @@ public class MeasurementToolFragment extends Fragment {
}
builder.setTitle(getString(R.string.exit_without_saving))
.setMessage(getString(R.string.unsaved_changes_will_be_lost))
.setNegativeButton(R.string.shared_string_cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dismiss(mapActivity);
}
});
.setNegativeButton(R.string.shared_string_cancel, null);
builder.show();
}
}