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