Update MyTracksProviderUtils api to make it clear

the valid values that can be used.
This commit is contained in:
Jimmy Shih
2012-12-18 15:02:50 -08:00
parent f94d27acca
commit 11ca9cc450
15 changed files with 72 additions and 48 deletions
@@ -82,9 +82,9 @@ public interface MyTracksProviderUtils {
* Gets a track cursor. The caller owns the returned cursor and is responsible
* for closing it.
*
* @param selection the selection
* @param selectionArgs the selection arguments
* @param sortOrder the sort order
* @param selection the selection. Can be null
* @param selectionArgs the selection arguments. Can be null
* @param sortOrder the sort order. Can be null
*/
public Cursor getTrackCursor(String selection, String[] selectionArgs, String sortOrder);
@@ -120,7 +120,7 @@ public interface MyTracksProviderUtils {
* deletion. The generator is used to update the next statistics waypoint.
*
* @param waypointId the waypoint id
* @param descriptionGenerator the description generator
* @param descriptionGenerator the description generator. Can be null for waypoint marker
*/
public void deleteWaypoint(long waypointId, DescriptionGenerator descriptionGenerator);
@@ -160,10 +160,10 @@ public interface MyTracksProviderUtils {
* Gets a waypoint cursor. The caller owns the returned cursor and is
* responsible for closing it.
*
* @param selection the selection
* @param selectionArgs the selection arguments
* @param sortOrder the sort order
* @param maxWaypoints the maximum number of waypoints to return
* @param selection the selection. Can be null
* @param selectionArgs the selection arguments. Can be null
* @param sortOrder the sort order. Can be null
* @param maxWaypoints the maximum number of waypoints to return. -1 for no limit
*/
public Cursor getWaypointCursor(
String selection, String[] selectionArgs, String sortOrder, int maxWaypoints);
@@ -173,8 +173,8 @@ public interface MyTracksProviderUtils {
* is responsible for closing it.
*
* @param trackId the track id
* @param minWaypointId the minimum waypoint id
* @param maxWaypoints the maximum number of waypoints to return
* @param minWaypointId the minimum waypoint id. -1L to ignore
* @param maxWaypoints the maximum number of waypoints to return. -1 for no limit
*/
public Cursor getWaypointCursor(long trackId, long minWaypointId, int maxWaypoints);
@@ -242,8 +242,8 @@ public interface MyTracksProviderUtils {
* responsible for closing it.
*
* @param trackId the track id
* @param startTrackPointId the starting track point id
* @param maxLocations maximum number of locations to return
* @param startTrackPointId the starting track point id. -1L to ignore
* @param maxLocations maximum number of locations to return. -1 for no limit
* @param descending true to sort the result in descending order (latest
* location first)
*/
@@ -262,8 +262,7 @@ public interface MyTracksProviderUtils {
* iteration, {@link LocationIterator#close()} must be called.
*
* @param trackId the track id
* @param startTrackPointId the start track point id or -1L to start from the
* first point
* @param startTrackPointId the starting track point id. -1L to ignore
* @param descending true to sort the result in descending order (latest
* location first)
* @param locationFactory the location factory
@@ -439,7 +439,8 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
@Override
public void deleteWaypoint(long waypointId, DescriptionGenerator descriptionGenerator) {
final Waypoint waypoint = getWaypoint(waypointId);
if (waypoint != null && waypoint.getType() == Waypoint.TYPE_STATISTICS) {
if (waypoint != null && waypoint.getType() == Waypoint.TYPE_STATISTICS
&& descriptionGenerator != null) {
final Waypoint nextWaypoint = getNextStatisticsWaypointAfter(waypoint);
if (nextWaypoint == null) {
Log.d(TAG, "Unable to find the next statistics marker after deleting one.");
@@ -510,7 +511,7 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
String selection = WaypointsColumns.TRACKID + "=? AND " + WaypointsColumns.TYPE + "=?";
int type = statistics ? Waypoint.TYPE_STATISTICS : Waypoint.TYPE_WAYPOINT;
String[] selectionArgs = new String[] { Long.toString(trackId), Integer.toString(type) };
cursor = getWaypointCursor(projection, selection, selectionArgs, WaypointsColumns._ID, 0);
cursor = getWaypointCursor(projection, selection, selectionArgs, WaypointsColumns._ID, -1);
if (cursor != null) {
int count = cursor.getCount();
/*
@@ -535,7 +536,7 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
Cursor cursor = null;
try {
cursor = getWaypointCursor(null, WaypointsColumns._ID + "=?",
new String[] { Long.toString(waypointId) }, WaypointsColumns._ID, 0);
new String[] { Long.toString(waypointId) }, WaypointsColumns._ID, 1);
if (cursor != null && cursor.moveToFirst()) {
return createWaypoint(cursor);
}
@@ -672,7 +673,7 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
if (sortOrder == null) {
sortOrder = WaypointsColumns._ID;
}
if (maxWaypoints > 0) {
if (maxWaypoints >= 0) {
sortOrder += " LIMIT " + maxWaypoints;
}
return contentResolver.query(
@@ -789,7 +790,7 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
if (descending) {
sortOrder += " DESC";
}
if (maxLocations > 0) {
if (maxLocations >= 0) {
sortOrder += " LIMIT " + maxLocations;
}
return getTrackPointCursor(null, selection, selectionArgs, sortOrder);