Cleanup: do not assume first waypoint contains (always) TripStatistics.

This commit is contained in:
Dennis Guse
2019-09-15 00:14:15 +02:00
parent 56685a9dec
commit 95b7c701a2
4 changed files with 28 additions and 17 deletions
@@ -99,7 +99,7 @@ public class FileTrackExporter implements TrackExporter {
try (Cursor cursor = contentProviderUtils.getWaypointCursor(track.getId(), -1L, ContentProviderUtils.MAX_LOADED_WAYPOINTS_POINTS)) {
if (cursor != null && cursor.moveToFirst()) {
// Intentionally skip first waypoint (contains statistics).
while (cursor.moveToNext()) {
for (int i = 0; i < cursor.getCount(); i++) {
if (Thread.interrupted()) {
throw new InterruptedException();
}
@@ -108,7 +108,11 @@ public class FileTrackExporter implements TrackExporter {
hasWaypoints = true;
}
Waypoint waypoint = contentProviderUtils.createWaypoint(cursor);
trackWriter.writeWaypoint(waypoint);
if (!waypoint.isTripStatistics()) {
trackWriter.writeWaypoint(waypoint);
}
cursor.moveToNext();
}
}
}
@@ -103,11 +103,7 @@ public class KmzTrackExporter implements TrackExporter {
for (Track track : tracks) {
try (Cursor cursor = contentProviderUtils.getWaypointCursor(track.getId(), -1L, -1)) {
if (cursor != null && cursor.moveToFirst()) {
/*
* Yes, this will skip the first waypoint and that is intentional as
* the first waypoint holds the stats for the track.
*/
while (cursor.moveToNext()) {
for (int i = 0; i < cursor.getCount(); i++) {
if (Thread.interrupted()) {
throw new InterruptedException();
}
@@ -115,6 +111,8 @@ public class KmzTrackExporter implements TrackExporter {
if (waypoint.hasPhoto()) {
addImage(context, zipOutputStream, waypoint.getPhotoUrl());
}
cursor.moveToNext();
}
}
}