Add play in earth with photo overlays

This commit is contained in:
Jimmy Shih
2013-08-19 15:54:32 -07:00
parent 24a343661d
commit ec3f0ddab3
5 changed files with 141 additions and 28 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.
@@ -788,6 +788,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) {