forked from upstream-mirrors/OpenTracks
TrackStatistics startTime/stopTime is null on creation.
This commit is contained in:
+1
-2
@@ -47,7 +47,6 @@ import static org.junit.Assert.assertNull;
|
|||||||
/**
|
/**
|
||||||
* Export a track to {@link TrackFileFormat} and verify that the import is identical.
|
* Export a track to {@link TrackFileFormat} and verify that the import is identical.
|
||||||
* <p>
|
* <p>
|
||||||
* TODO: test ignores {@link TrackStatistics} for now.
|
|
||||||
*/
|
*/
|
||||||
@RunWith(JUnit4.class)
|
@RunWith(JUnit4.class)
|
||||||
public class ExportImportTest {
|
public class ExportImportTest {
|
||||||
@@ -431,7 +430,7 @@ public class ExportImportTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static TrackPoint createTrackPoint(long time, double latitude, double longitude, float accuracy, long speed, long altitude, float elevationGain, float heartRate, float cyclingCadence, float power) {
|
private static TrackPoint createTrackPoint(long time, double latitude, double longitude, float accuracy, long speed, long altitude, float elevationGain, float heartRate, float cyclingCadence, float power) {
|
||||||
Location location = new Location("gps");
|
Location location = new Location("");
|
||||||
location.setTime(time);
|
location.setTime(time);
|
||||||
location.setLongitude(longitude);
|
location.setLongitude(longitude);
|
||||||
location.setLatitude(latitude);
|
location.setLatitude(latitude);
|
||||||
|
|||||||
@@ -264,7 +264,6 @@ public class ContentProviderUtils {
|
|||||||
ContentValues values = new ContentValues();
|
ContentValues values = new ContentValues();
|
||||||
TrackStatistics trackStatistics = track.getTrackStatistics();
|
TrackStatistics trackStatistics = track.getTrackStatistics();
|
||||||
|
|
||||||
// Value < 0 indicates no id is available
|
|
||||||
if (track.getId() != null) {
|
if (track.getId() != null) {
|
||||||
values.put(TracksColumns._ID, track.getId().getId());
|
values.put(TracksColumns._ID, track.getId().getId());
|
||||||
}
|
}
|
||||||
@@ -272,8 +271,12 @@ public class ContentProviderUtils {
|
|||||||
values.put(TracksColumns.NAME, track.getName());
|
values.put(TracksColumns.NAME, track.getName());
|
||||||
values.put(TracksColumns.DESCRIPTION, track.getDescription());
|
values.put(TracksColumns.DESCRIPTION, track.getDescription());
|
||||||
values.put(TracksColumns.CATEGORY, track.getCategory());
|
values.put(TracksColumns.CATEGORY, track.getCategory());
|
||||||
values.put(TracksColumns.STARTTIME, trackStatistics.getStartTime().toEpochMilli());
|
if (trackStatistics.getStartTime() != null) {
|
||||||
values.put(TracksColumns.STOPTIME, trackStatistics.getStopTime().toEpochMilli());
|
values.put(TracksColumns.STARTTIME, trackStatistics.getStartTime().toEpochMilli());
|
||||||
|
}
|
||||||
|
if (trackStatistics.getStopTime() != null) {
|
||||||
|
values.put(TracksColumns.STOPTIME, trackStatistics.getStopTime().toEpochMilli());
|
||||||
|
}
|
||||||
values.put(TracksColumns.TOTALDISTANCE, trackStatistics.getTotalDistance());
|
values.put(TracksColumns.TOTALDISTANCE, trackStatistics.getTotalDistance());
|
||||||
values.put(TracksColumns.TOTALTIME, trackStatistics.getTotalTime().toMillis());
|
values.put(TracksColumns.TOTALTIME, trackStatistics.getTotalTime().toMillis());
|
||||||
values.put(TracksColumns.MOVINGTIME, trackStatistics.getMovingTime().toMillis());
|
values.put(TracksColumns.MOVINGTIME, trackStatistics.getMovingTime().toMillis());
|
||||||
|
|||||||
@@ -341,10 +341,6 @@ public class CustomContentProvider extends ContentProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Uri insertTrack(Uri url, ContentValues contentValues) {
|
private Uri insertTrack(Uri url, ContentValues contentValues) {
|
||||||
boolean hasStartTime = contentValues.containsKey(TracksColumns.STARTTIME);
|
|
||||||
if (!hasStartTime) {
|
|
||||||
throw new IllegalArgumentException("Both start time and start id values are required.");
|
|
||||||
}
|
|
||||||
long rowId = db.insert(TracksColumns.TABLE_NAME, TracksColumns._ID, contentValues);
|
long rowId = db.insert(TracksColumns.TABLE_NAME, TracksColumns._ID, contentValues);
|
||||||
if (rowId >= 0) {
|
if (rowId >= 0) {
|
||||||
return ContentUris.appendId(TracksColumns.CONTENT_URI.buildUpon(), rowId).build();
|
return ContentUris.appendId(TracksColumns.CONTENT_URI.buildUpon(), rowId).build();
|
||||||
|
|||||||
@@ -112,7 +112,8 @@ public class TrackStatistics {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void reset() {
|
public void reset() {
|
||||||
setStartTime(Instant.ofEpochMilli(0)); //TODO should probably initialized with null
|
startTime = null;
|
||||||
|
stopTime = null;
|
||||||
|
|
||||||
setTotalDistance(0);
|
setTotalDistance(0);
|
||||||
setTotalTime(Duration.ofSeconds(0));
|
setTotalTime(Duration.ofSeconds(0));
|
||||||
|
|||||||
Reference in New Issue
Block a user