Merge heads

This commit is contained in:
youtaol
2013-08-22 10:14:45 +08:00
parent 83b1fb67bf
commit b6b54923b2
37 changed files with 434 additions and 221 deletions
@@ -237,6 +237,15 @@ public interface MyTracksProviderUtils {
*/
public long getLastTrackPointId(long trackId);
/**
* Gets the track point id of a location.
*
* @param trackId the track id
* @param location the location
* @return track point id if the location is in the track. -1L otherwise.
*/
public long getTrackPointId(long trackId, Location location);
/**
* Gets the first valid location for a track. Returns null if it doesn't
* exist.
@@ -794,6 +794,31 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
}
return -1L;
}
@Override
public long getTrackPointId(long trackId, Location location) {
if (trackId < 0) {
return -1L;
}
Cursor cursor = null;
try {
String selection = TrackPointsColumns._ID + "=(select max(" + TrackPointsColumns._ID
+ ") from " + TrackPointsColumns.TABLE_NAME + " WHERE " + TrackPointsColumns.TRACKID
+ "=? AND " + TrackPointsColumns.TIME + "=?)";
String[] selectionArgs = new String[] {
Long.toString(trackId), Long.toString(location.getTime()) };
cursor = getTrackPointCursor(new String[] { TrackPointsColumns._ID }, selection,
selectionArgs, TrackPointsColumns._ID);
if (cursor != null && cursor.moveToFirst()) {
return cursor.getLong(cursor.getColumnIndexOrThrow(TrackPointsColumns._ID));
}
} finally {
if (cursor != null) {
cursor.close();
}
}
return -1L;
}
@Override
public Location getFirstValidTrackPoint(long trackId) {