forked from upstream-mirrors/OpenTracks
Merge heads
This commit is contained in:
@@ -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.
|
||||
*
|
||||
|
||||
+18
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user