forked from upstream-mirrors/OpenTracks
Removed unnecessary Track.startId and Track.stopId.
This commit is contained in:
-2
@@ -128,7 +128,5 @@ public abstract class AbstractTestFileTrackImporter {
|
|||||||
if (time != -1L) {
|
if (time != -1L) {
|
||||||
Assert.assertEquals(time, track.getTripStatistics().getStartTime());
|
Assert.assertEquals(time, track.getTripStatistics().getStartTime());
|
||||||
}
|
}
|
||||||
Assert.assertNotSame(-1, track.getStartId());
|
|
||||||
Assert.assertNotSame(-1, track.getStopId());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -142,12 +142,6 @@ public class ContentProviderUtils {
|
|||||||
if (!cursor.isNull(categoryIndex)) {
|
if (!cursor.isNull(categoryIndex)) {
|
||||||
track.setCategory(cursor.getString(categoryIndex));
|
track.setCategory(cursor.getString(categoryIndex));
|
||||||
}
|
}
|
||||||
if (!cursor.isNull(startIdIndex)) {
|
|
||||||
track.setStartId(cursor.getLong(startIdIndex));
|
|
||||||
}
|
|
||||||
if (!cursor.isNull(stopIdIndex)) {
|
|
||||||
track.setStopId(cursor.getLong(stopIdIndex));
|
|
||||||
}
|
|
||||||
if (!cursor.isNull(startTimeIndex)) {
|
if (!cursor.isNull(startTimeIndex)) {
|
||||||
tripStatistics.setStartTime(cursor.getLong(startTimeIndex));
|
tripStatistics.setStartTime(cursor.getLong(startTimeIndex));
|
||||||
}
|
}
|
||||||
@@ -224,20 +218,16 @@ public class ContentProviderUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes track points and waypoints of a track. Assumes
|
* Deletes track points and waypoints of a track.
|
||||||
* {@link TracksColumns#STARTID}, {@link TracksColumns#STOPID}, and
|
* Assumes {@link TracksColumns#NUMPOINTS} will be updated by the caller.
|
||||||
* {@link TracksColumns#NUMPOINTS} will be updated by the caller.
|
|
||||||
*
|
*
|
||||||
* @param trackId the track id
|
* @param trackId the track id
|
||||||
*/
|
*/
|
||||||
private void deleteTrackPointsAndWaypoints(Context context, long trackId) {
|
private void deleteTrackPointsAndWaypoints(Context context, long trackId) {
|
||||||
Track track = getTrack(trackId);
|
String where = TrackPointsColumns.TRACKID + "=?";
|
||||||
if (track != null) {
|
String[] selectionArgs = new String[]{Long.toString(trackId)};
|
||||||
String where = TrackPointsColumns._ID + ">=? AND " + TrackPointsColumns._ID + "<=?";
|
contentResolver.delete(TrackPointsColumns.CONTENT_URI, where, selectionArgs);
|
||||||
String[] selectionArgs = new String[]{
|
|
||||||
Long.toString(track.getStartId()), Long.toString(track.getStopId())};
|
|
||||||
contentResolver.delete(TrackPointsColumns.CONTENT_URI, where, selectionArgs);
|
|
||||||
}
|
|
||||||
contentResolver.delete(WaypointsColumns.CONTENT_URI, WaypointsColumns.TRACKID + "=?",
|
contentResolver.delete(WaypointsColumns.CONTENT_URI, WaypointsColumns.TRACKID + "=?",
|
||||||
new String[]{Long.toString(trackId)});
|
new String[]{Long.toString(trackId)});
|
||||||
deleteDirectoryRecurse(context, FileUtils.getPhotoDir(trackId));
|
deleteDirectoryRecurse(context, FileUtils.getPhotoDir(trackId));
|
||||||
@@ -354,8 +344,6 @@ 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.STARTID, track.getStartId());
|
|
||||||
values.put(TracksColumns.STOPID, track.getStopId());
|
|
||||||
values.put(TracksColumns.STARTTIME, tripStatistics.getStartTime());
|
values.put(TracksColumns.STARTTIME, tripStatistics.getStartTime());
|
||||||
values.put(TracksColumns.STOPTIME, tripStatistics.getStopTime());
|
values.put(TracksColumns.STOPTIME, tripStatistics.getStopTime());
|
||||||
values.put(TracksColumns.NUMPOINTS, track.getNumberOfPoints());
|
values.put(TracksColumns.NUMPOINTS, track.getNumberOfPoints());
|
||||||
@@ -743,6 +731,7 @@ public class ContentProviderUtils {
|
|||||||
*
|
*
|
||||||
* @param trackId the track id
|
* @param trackId the track id
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public long getFirstTrackPointId(long trackId) {
|
public long getFirstTrackPointId(long trackId) {
|
||||||
if (trackId < 0) {
|
if (trackId < 0) {
|
||||||
return -1L;
|
return -1L;
|
||||||
@@ -765,6 +754,7 @@ public class ContentProviderUtils {
|
|||||||
*
|
*
|
||||||
* @param trackId the track id
|
* @param trackId the track id
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public long getLastTrackPointId(long trackId) {
|
public long getLastTrackPointId(long trackId) {
|
||||||
if (trackId < 0) {
|
if (trackId < 0) {
|
||||||
return -1L;
|
return -1L;
|
||||||
|
|||||||
@@ -334,8 +334,7 @@ public abstract class CustomContentProvider extends ContentProvider {
|
|||||||
*/
|
*/
|
||||||
private Uri insertTrack(Uri url, ContentValues contentValues) {
|
private Uri insertTrack(Uri url, ContentValues contentValues) {
|
||||||
boolean hasStartTime = contentValues.containsKey(TracksColumns.STARTTIME);
|
boolean hasStartTime = contentValues.containsKey(TracksColumns.STARTTIME);
|
||||||
boolean hasStartId = contentValues.containsKey(TracksColumns.STARTID);
|
if (!hasStartTime) {
|
||||||
if (!hasStartTime || !hasStartId) {
|
|
||||||
throw new IllegalArgumentException("Both start time and start id values are required.");
|
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);
|
||||||
|
|||||||
@@ -35,8 +35,6 @@ public class Track {
|
|||||||
private String name = "";
|
private String name = "";
|
||||||
private String description = "";
|
private String description = "";
|
||||||
private String category = "";
|
private String category = "";
|
||||||
private long startId = -1L;
|
|
||||||
private long stopId = -1L;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The number of location points (present even if the points themselves are not loaded)
|
* The number of location points (present even if the points themselves are not loaded)
|
||||||
@@ -84,22 +82,6 @@ public class Track {
|
|||||||
this.category = category;
|
this.category = category;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getStartId() {
|
|
||||||
return startId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStartId(long startId) {
|
|
||||||
this.startId = startId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getStopId() {
|
|
||||||
return stopId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStopId(long stopId) {
|
|
||||||
this.stopId = stopId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getNumberOfPoints() {
|
public int getNumberOfPoints() {
|
||||||
return numberOfPoints;
|
return numberOfPoints;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,8 +38,10 @@ public interface TracksColumns extends BaseColumns {
|
|||||||
String NAME = "name"; // track name
|
String NAME = "name"; // track name
|
||||||
String DESCRIPTION = "description"; // track description
|
String DESCRIPTION = "description"; // track description
|
||||||
String CATEGORY = "category"; // track activity type
|
String CATEGORY = "category"; // track activity type
|
||||||
String STARTID = "startid"; // first track point id
|
@Deprecated
|
||||||
String STOPID = "stopid"; // last track point id
|
String STARTID = "startid"; // first track point id // TODO UNUSED
|
||||||
|
@Deprecated
|
||||||
|
String STOPID = "stopid"; // last track point id // TODO UNUSED
|
||||||
String STARTTIME = "starttime"; // track start time
|
String STARTTIME = "starttime"; // track start time
|
||||||
String STOPTIME = "stoptime"; // track stop time
|
String STOPTIME = "stoptime"; // track stop time
|
||||||
String NUMPOINTS = "numpoints"; // number of track points
|
String NUMPOINTS = "numpoints"; // number of track points
|
||||||
|
|||||||
@@ -357,11 +357,6 @@ abstract class AbstractFileTrackImporter extends DefaultHandler implements Track
|
|||||||
*/
|
*/
|
||||||
protected void insertTrackPoint(Location location) {
|
protected void insertTrackPoint(Location location) {
|
||||||
insertLocation(location);
|
insertLocation(location);
|
||||||
|
|
||||||
if (trackData.track.getStartId() == -1L) {
|
|
||||||
// Flush the location to set the track start id and the track end id
|
|
||||||
flushLocations(trackData);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -479,10 +474,6 @@ abstract class AbstractFileTrackImporter extends DefaultHandler implements Track
|
|||||||
}
|
}
|
||||||
contentProviderUtils.bulkInsertTrackPoint(data.bufferedLocations, data.numBufferedLocations, data.track.getId());
|
contentProviderUtils.bulkInsertTrackPoint(data.bufferedLocations, data.numBufferedLocations, data.track.getId());
|
||||||
data.numBufferedLocations = 0;
|
data.numBufferedLocations = 0;
|
||||||
if (data.track.getStartId() == -1L) {
|
|
||||||
data.track.setStartId(contentProviderUtils.getFirstTrackPointId(data.track.getId()));
|
|
||||||
}
|
|
||||||
data.track.setStopId(contentProviderUtils.getLastTrackPointId(data.track.getId()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -463,7 +463,7 @@ public class TrackRecordingService extends Service {
|
|||||||
insertLocation(track, lastLocation, getLastValidTrackPointInCurrentSegment(trackId));
|
insertLocation(track, lastLocation, getLastValidTrackPointInCurrentSegment(trackId));
|
||||||
|
|
||||||
// Update the recording track time
|
// Update the recording track time
|
||||||
updateRecordingTrack(track, contentProviderUtils.getLastTrackPointId(trackId), false);
|
updateRecordingTrack(track, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
String trackName = TrackNameUtils.getTrackName(this, trackId, track.getTripStatistics().getStartTime());
|
String trackName = TrackNameUtils.getTrackName(this, trackId, track.getTripStatistics().getStartTime());
|
||||||
@@ -687,9 +687,8 @@ public class TrackRecordingService extends Service {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
Uri uri = contentProviderUtils.insertTrackPoint(location, track.getId());
|
Uri uri = contentProviderUtils.insertTrackPoint(location, track.getId());
|
||||||
long trackPointId = Long.parseLong(uri.getLastPathSegment());
|
|
||||||
trackTripStatisticsUpdater.addLocation(location, recordingDistanceInterval);
|
trackTripStatisticsUpdater.addLocation(location, recordingDistanceInterval);
|
||||||
updateRecordingTrack(track, trackPointId, LocationUtils.isValidLocation(location));
|
updateRecordingTrack(track, LocationUtils.isValidLocation(location));
|
||||||
} catch (SQLiteException e) {
|
} catch (SQLiteException e) {
|
||||||
/*
|
/*
|
||||||
* Insert failed, most likely because of SqlLite error code 5 (SQLite_BUSY).
|
* Insert failed, most likely because of SqlLite error code 5 (SQLite_BUSY).
|
||||||
@@ -705,16 +704,9 @@ public class TrackRecordingService extends Service {
|
|||||||
* Increase the number of points if it is a new and valid track point.
|
* Increase the number of points if it is a new and valid track point.
|
||||||
*
|
*
|
||||||
* @param track the track
|
* @param track the track
|
||||||
* @param lastTrackPointId the last track point id
|
|
||||||
* @param increaseNumberOfPoints true to increase the number of points
|
* @param increaseNumberOfPoints true to increase the number of points
|
||||||
*/
|
*/
|
||||||
private void updateRecordingTrack(Track track, long lastTrackPointId, boolean increaseNumberOfPoints) {
|
private void updateRecordingTrack(Track track, boolean increaseNumberOfPoints) {
|
||||||
if (lastTrackPointId >= 0) {
|
|
||||||
if (track.getStartId() < 0) {
|
|
||||||
track.setStartId(lastTrackPointId);
|
|
||||||
}
|
|
||||||
track.setStopId(lastTrackPointId);
|
|
||||||
}
|
|
||||||
if (increaseNumberOfPoints) {
|
if (increaseNumberOfPoints) {
|
||||||
track.setNumberOfPoints(track.getNumberOfPoints() + 1);
|
track.setNumberOfPoints(track.getNumberOfPoints() + 1);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user