addresses a crash when trying to save an empty recording (see #21)

master
y20k 2018-09-17 20:07:33 +02:00
parent b44e39667a
commit 2f39017b76
1 changed files with 21 additions and 5 deletions

View File

@ -309,11 +309,17 @@ public class MainActivityMapFragment extends Fragment implements TrackbookKeys {
switch(requestCode) {
case RESULT_SAVE_DIALOG:
if (resultCode == Activity.RESULT_OK) {
// user chose SAVE - clear map AND save track
// user chose SAVE
if (mTrack.getSize() > 0) {
// Track is not empty - clear map AND save track
clearMap(true);
// FloatingActionButton state is already being handled in MainActivity
((MainActivity)mActivity).onFloatingActionButtonResult(requestCode, resultCode);
LogHelper.v(LOG_TAG, "Save dialog result: SAVE");
} else {
// track is empty
handleEmptyRecordingSaveRequest();
}
} else if (resultCode == Activity.RESULT_CANCELED){
LogHelper.v(LOG_TAG, "Save dialog result: CANCEL");
}
@ -446,6 +452,16 @@ public class MainActivityMapFragment extends Fragment implements TrackbookKeys {
}
/* Handles case when user chose to save recording with zero waypoints */ // todo implement
private void handleEmptyRecordingSaveRequest() {
// todo ask user what to do
Toast.makeText(mActivity, " Error. Empty recording. Clearing Map.", Toast.LENGTH_LONG).show(); // todo user alert (clear track?)
// todo change (solution for now: insta-clear)
clearMap(false);
((MainActivity)mActivity).onFloatingActionButtonResult(RESULT_CLEAR_DIALOG, Activity.RESULT_OK);
}
/* Start preliminary tracking for map */
private void startPreliminaryTracking() {
if (mLocationSystemSetting && !mLocalTrackerRunning) {