forked from upstream-mirrors/OpenTracks
In TrackRecordingService, make sure all fields of a waypoint
are set consistently when creating a marker.
This commit is contained in:
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package com.google.android.apps.mytracks.content;
|
||||
|
||||
import com.google.android.apps.mytracks.stats.TripStatistics;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
/**
|
||||
@@ -37,9 +39,9 @@ public interface DescriptionGenerator {
|
||||
Track track, Vector<Double> distances, Vector<Double> elevations, boolean html);
|
||||
|
||||
/**
|
||||
* Generate a waypoint description.
|
||||
* Generate a waypoint description from a trip statistics.
|
||||
*
|
||||
* @param waypoint the waypoint
|
||||
* @param tripStatistics the trip statistics
|
||||
*/
|
||||
public String generateWaypointDescription(Waypoint waypoint);
|
||||
public String generateWaypointDescription(TripStatistics tripStatistics);
|
||||
}
|
||||
|
||||
@@ -293,7 +293,14 @@ public interface MyTracksProviderUtils {
|
||||
*
|
||||
* @param trackId the track id
|
||||
*/
|
||||
public long getLastLocationId(long trackId);
|
||||
public long getLastTrackLocationId(long trackId);
|
||||
|
||||
/**
|
||||
* Gets the last location for a track. Returns -1L if it doesn't exist.
|
||||
*
|
||||
* @param trackId the track id
|
||||
*/
|
||||
public Location getLastTrackLocation(long trackId);
|
||||
|
||||
/**
|
||||
* Inserts a track point.
|
||||
|
||||
+15
-2
@@ -556,7 +556,8 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
|
||||
Log.d(TAG, "Unable to find the next statistics marker after deleting one.");
|
||||
} else {
|
||||
nextWaypoint.getTripStatistics().merge(waypoint.getTripStatistics());
|
||||
nextWaypoint.setDescription(descriptionGenerator.generateWaypointDescription(nextWaypoint));
|
||||
nextWaypoint.setDescription(
|
||||
descriptionGenerator.generateWaypointDescription(nextWaypoint.getTripStatistics()));
|
||||
if (!updateWaypoint(nextWaypoint)) {
|
||||
Log.e(TAG, "Unable to update the next statistics marker after deleting one.");
|
||||
}
|
||||
@@ -928,7 +929,7 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLastLocationId(long trackId) {
|
||||
public long getLastTrackLocationId(long trackId) {
|
||||
if (trackId < 0) {
|
||||
return -1L;
|
||||
}
|
||||
@@ -950,6 +951,18 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
|
||||
}
|
||||
return -1L;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getLastTrackLocation(long trackId) {
|
||||
if (trackId < 0) {
|
||||
return null;
|
||||
}
|
||||
String selection = TrackPointsColumns._ID + "=(select max(" + TrackPointsColumns._ID
|
||||
+ ") from " + TrackPointsColumns.TABLE_NAME + " WHERE " + TrackPointsColumns.TRACKID
|
||||
+ "=?)";
|
||||
String[] selectionArgs = new String[] { Long.toString(trackId) };
|
||||
return findLocationBy(selection, selectionArgs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Uri insertTrackPoint(Location location, long trackId) {
|
||||
|
||||
@@ -33,22 +33,39 @@ public final class Waypoint implements Parcelable {
|
||||
public static final int TYPE_WAYPOINT = 0;
|
||||
public static final int TYPE_STATISTICS = 1;
|
||||
|
||||
private long id = -1;
|
||||
private long id = -1L;
|
||||
private String name = "";
|
||||
private String description = "";
|
||||
private String category = "";
|
||||
private String icon = "";
|
||||
private long trackId = -1;
|
||||
private long trackId = -1L;
|
||||
private int type = 0;
|
||||
private double length = 0.0;
|
||||
private long duration = 0;
|
||||
private long startId = -1;
|
||||
private long stopId = -1;
|
||||
private long startId = -1L;
|
||||
private long stopId = -1L;
|
||||
private Location location = null;
|
||||
private TripStatistics tripStatistics = null;
|
||||
|
||||
public Waypoint() {}
|
||||
|
||||
public Waypoint(String name, String description, String category, String icon, long trackId,
|
||||
int type, double length, long duration, long startId, long stopId, Location location,
|
||||
TripStatistics tripStatistics) {
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.category = category;
|
||||
this.icon = icon;
|
||||
this.trackId = trackId;
|
||||
this.type = type;
|
||||
this.length = length;
|
||||
this.duration = duration;
|
||||
this.startId = startId;
|
||||
this.stopId = stopId;
|
||||
this.location = location;
|
||||
this.tripStatistics = tripStatistics;
|
||||
}
|
||||
|
||||
private Waypoint(Parcel source) {
|
||||
id = source.readLong();
|
||||
name = source.readString();
|
||||
|
||||
Reference in New Issue
Block a user