Open track activity after saving

This commit is contained in:
PavelRatushny 2017-08-11 18:32:59 +03:00
parent 2796cb25ee
commit 1392d73e07

View file

@ -553,14 +553,14 @@ public class MeasurementToolFragment extends Fragment {
} }
private void saveNewGpx(File dir, String fileName, boolean checked) { private void saveNewGpx(File dir, String fileName, boolean checked) {
saveGpx(dir, fileName, checked, null); saveGpx(dir, fileName, checked, null, false);
} }
private void saveExistingGpx(GPXFile gpx, boolean showOnMap) { private void saveExistingGpx(GPXFile gpx, boolean showOnMap) {
saveGpx(null, null, showOnMap, gpx); saveGpx(null, null, showOnMap, gpx, true);
} }
private void saveGpx(final File dir, final String fileName, final boolean showOnMap, final GPXFile gpx) { private void saveGpx(final File dir, final String fileName, final boolean showOnMap, final GPXFile gpx, final boolean openTrackActivity) {
new AsyncTask<Void, Void, String>() { new AsyncTask<Void, Void, String>() {
private ProgressDialog progressDialog; private ProgressDialog progressDialog;
@ -624,19 +624,23 @@ public class MeasurementToolFragment extends Fragment {
@Override @Override
protected void onPostExecute(String warning) { protected void onPostExecute(String warning) {
MapActivity activity = getMapActivity(); MapActivity activity = getMapActivity();
if (progressDialog != null && progressDialog.isShowing()) {
progressDialog.dismiss();
}
if (activity != null) { if (activity != null) {
activity.refreshMap();
if (warning == null) { if (warning == null) {
saved = true;
if (openTrackActivity) {
dismiss(activity);
} else {
Toast.makeText(activity, Toast.makeText(activity,
MessageFormat.format(getString(R.string.gpx_saved_sucessfully), toSave.getAbsolutePath()), MessageFormat.format(getString(R.string.gpx_saved_sucessfully), toSave.getAbsolutePath()),
Toast.LENGTH_LONG).show(); Toast.LENGTH_LONG).show();
saved = true; }
} else { } else {
Toast.makeText(activity, warning, Toast.LENGTH_LONG).show(); Toast.makeText(activity, warning, Toast.LENGTH_LONG).show();
} }
activity.refreshMap();
}
if (progressDialog != null && progressDialog.isShowing()) {
progressDialog.dismiss();
} }
} }
}.execute(); }.execute();