fixes a crash when resuming a track with zero (or one) waypoint(s)

master
y20k 2018-09-18 13:01:00 +02:00
parent 9e08446436
commit 27508ce8cc
1 changed files with 6 additions and 4 deletions

View File

@ -395,7 +395,7 @@ public class TrackerService extends Service implements TrackbookKeys, SensorEven
boolean success = false; boolean success = false;
Location previousLocation = null; Location previousLocation = null;
int trackSize = mTrack.getWayPoints().size(); int trackSize = mTrack.getSize();
if (trackSize == 0) { if (trackSize == 0) {
// if accurate AND current // if accurate AND current
@ -430,9 +430,11 @@ public class TrackerService extends Service implements TrackbookKeys, SensorEven
if (success) { if (success) {
if (mResumedFlag) { if (mResumedFlag) {
int lastWayPoint = mTrack.getSize() - 2;
if (lastWayPoint >= 0) {
// mark last location as stop over // mark last location as stop over
int lastWayPoint = mTrack.getWayPoints().size() - 2;
mTrack.getWayPoints().get(lastWayPoint).setIsStopOver(true); mTrack.getWayPoints().get(lastWayPoint).setIsStopOver(true);
}
mResumedFlag = false; mResumedFlag = false;
} else { } else {
// update distance, if not resumed // update distance, if not resumed