Merge heads

This commit is contained in:
youtaol
2013-10-30 11:16:07 +08:00
parent 7823ca4eec
commit 7cc1f878b4
12 changed files with 172 additions and 99 deletions
@@ -190,6 +190,13 @@ public interface MyTracksProviderUtils {
*/
public Cursor getWaypointCursor(long trackId, long minWaypointId, int maxWaypoints);
/**
* Gets the number of waypoints for a track.
*
* @param trackId the track id
*/
public int getWaypointCount(long trackId);
/**
* Inserts a waypoint.
*
@@ -657,6 +657,24 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
return getWaypointCursor(null, selection, selectionArgs, WaypointsColumns._ID, maxWaypoints);
}
@Override
public int getWaypointCount(long trackId) {
if (trackId < 0) {
return 0;
}
String[] projection = new String[] { "count(*) AS count" };
String selection = WaypointsColumns.TRACKID + "=?";
String[] selectionArgs = new String[] { Long.toString(trackId) };
Cursor cursor = contentResolver.query(
WaypointsColumns.CONTENT_URI, projection, selection, selectionArgs, WaypointsColumns._ID);
cursor.moveToFirst();
int count = cursor.getInt(0);
// not count the first waypoint
return count > 0 ? count - 1 : 0;
}
@Override
public Uri insertWaypoint(Waypoint waypoint) {
waypoint.setId(-1L);