Remove unused methods in MyTracksProviderUtils

Change getLastValidLocation to getLastValidTrackLocation, thus
all location related api takes trackId as an argument.
This commit is contained in:
Jimmy Shih
2012-08-24 14:05:50 -07:00
parent c6861d1e49
commit 784ce8bc26
4 changed files with 32 additions and 346 deletions
@@ -16,7 +16,6 @@
package com.google.android.apps.mytracks.content;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.location.Location;
@@ -70,18 +69,6 @@ public interface MyTracksProviderUtils {
*/
public Track getLastTrack();
/**
* Gets the last track id. Returns -1L if doesn't exist.
*/
public long getLastTrackId();
/**
* Returns true if a track exists.
*
* @param trackId the track id
*/
public boolean trackExists(long trackId);
/**
* Inserts a track.
* <p>
@@ -120,13 +107,6 @@ public interface MyTracksProviderUtils {
*/
public Track createTrack(Cursor cursor);
/**
* Creates a {@link ContentValues} from a track.
*
* @param track the track
*/
public ContentValues createContentValues(Track track);
/**
* Gets a waypoint cursor. The caller owns the returned cursor and is
* responsible for closing it.
@@ -149,15 +129,6 @@ public interface MyTracksProviderUtils {
*/
public Cursor getWaypointsCursor(long trackId, long minWaypointId, int maxWaypoints);
/**
* Gets the first recorded waypoint for a track. The first waypoint is special
* as it contains the stats for the current segment. Returns null if it
* doesn't exist.
*
* @param trackId the track id
*/
public Waypoint getFirstWaypoint(long trackId);
/**
* Gets the first waypoint id for a track. The first waypoint is special as it
* contains the stats for the current segment. Returns -1L if it doesn't
@@ -167,13 +138,6 @@ public interface MyTracksProviderUtils {
*/
public long getFirstWaypointId(long trackId);
/**
* Gets the last waypoint id for a track. Returns -1L if it doesn't exist.
*
* @param trackId the track id
*/
public long getLastWaypointId(long trackId);
/**
* Gets the last statistics waypoint for a track. Returns null if it doesn't exist.
*
@@ -190,14 +154,6 @@ public interface MyTracksProviderUtils {
*/
public int getNextMarkerNumber(long trackId, boolean statistics);
/**
* Gets the next statistics waypoint after the given waypoint. Returns null if
* it doesn't exists.
*
* @param waypoint the given waypoint
*/
public Waypoint getNextStatisticsWaypointAfter(Waypoint waypoint);
/**
* Gets a waypoint from a waypoint id. Returns null if not found.
*
@@ -237,23 +193,6 @@ public interface MyTracksProviderUtils {
*/
public Waypoint createWaypoint(Cursor cursor);
/**
* Gets the first recorded location. Returns null if it doesn't exist.
*/
public Location getFirstLocation();
/**
* Gets the last valid recorded location. Returns null if it doesn't exist.
*/
public Location getLastValidLocation();
/**
* Gets a location by track point id. Returns null if not found.
*
* @param trackPointId the track point id
*/
public Location getLocation(long trackPointId);
/**
* Creates a location cursor. The caller owns the returned cursor and is
* responsible for closing it.
@@ -296,12 +235,19 @@ public interface MyTracksProviderUtils {
public long getLastTrackLocationId(long trackId);
/**
* Gets the last location for a track. Returns -1L if it doesn't exist.
* Gets the last location for a track. Returns null if it doesn't exist.
*
* @param trackId the track id
*/
public Location getLastTrackLocation(long trackId);
/**
* Gets the last valid location for a track. Returns null if it doesn't exist.
*
* @param trackId the track id
*/
public Location getLastValidTrackLocation(long trackId);
/**
* Inserts a track point.
*
@@ -322,14 +268,6 @@ public interface MyTracksProviderUtils {
*/
public int bulkInsertTrackPoints(Location[] locations, int length, long trackId);
/**
* Fills a location from a cursor.
*
* @param cursor the cursor pointing to the location
* @param location the location to be overwritten
*/
public void fillLocation(Cursor cursor, Location location);
/**
* Creates a location object from a cursor.
*
@@ -120,45 +120,6 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
return null;
}
@Override
public long getLastTrackId() {
Cursor cursor = null;
try {
String selection = TracksColumns._ID + "=(select max(" + TracksColumns._ID + ") from "
+ TracksColumns.TABLE_NAME + ")";
cursor = getTracksCursor(
new String[] { TracksColumns._ID }, selection, null, TracksColumns._ID);
if (cursor != null && cursor.moveToFirst()) {
return cursor.getLong(cursor.getColumnIndexOrThrow(TracksColumns._ID));
}
} finally {
if (cursor != null) {
cursor.close();
}
}
return -1L;
}
@Override
public boolean trackExists(long trackId) {
if (trackId < 0) {
return false;
}
Cursor cursor = null;
try {
cursor = getTracksCursor(new String[] { TracksColumns._ID }, TracksColumns._ID + "=?",
new String[] { Long.toString(trackId) }, TracksColumns._ID);
if (cursor != null && cursor.moveToNext()) {
return true;
}
} finally {
if (cursor != null) {
cursor.close();
}
}
return false;
}
@Override
public Uri insertTrack(Track track) {
return contentResolver.insert(TracksColumns.CONTENT_URI, createContentValues(track));
@@ -298,8 +259,7 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
return track;
}
@Override
public ContentValues createContentValues(Track track) {
private ContentValues createContentValues(Track track) {
ContentValues values = new ContentValues();
TripStatistics tripStatistics = track.getTripStatistics();
@@ -381,26 +341,6 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
return getWaypointsCursor(null, selection, selectionArgs, WaypointsColumns._ID, maxWaypoints);
}
@Override
public Waypoint getFirstWaypoint(long trackId) {
if (trackId < 0) {
return null;
}
Cursor cursor = null;
try {
cursor = getWaypointsCursor(null, WaypointsColumns.TRACKID + "=?", new String[] {
Long.toString(trackId) }, WaypointsColumns._ID, 1);
if (cursor != null && cursor.moveToFirst()) {
return createWaypoint(cursor);
}
} finally {
if (cursor != null) {
cursor.close();
}
}
return null;
}
@Override
public long getFirstWaypointId(long trackId) {
if (trackId < 0) {
@@ -422,27 +362,6 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
return -1L;
}
@Override
public long getLastWaypointId(long trackId) {
if (trackId < 0) {
return -1;
}
Cursor cursor = null;
try {
cursor = getWaypointsCursor(new String[] { WaypointsColumns._ID },
WaypointsColumns.TRACKID + "=?", new String[] { Long.toString(trackId) },
WaypointsColumns._ID + " DESC", 1);
if (cursor != null && cursor.moveToFirst()) {
return cursor.getLong(cursor.getColumnIndexOrThrow(WaypointsColumns._ID));
}
} finally {
if (cursor != null) {
cursor.close();
}
}
return -1L;
}
@Override
public Waypoint getLastStatisticsWaypoint(long trackId) {
if (trackId < 0) {
@@ -494,8 +413,7 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
return -1;
}
@Override
public Waypoint getNextStatisticsWaypointAfter(Waypoint waypoint) {
private Waypoint getNextStatisticsWaypointAfter(Waypoint waypoint) {
Cursor cursor = null;
try {
String selection = WaypointsColumns._ID + ">? AND " + WaypointsColumns.TRACKID + "=? AND "
@@ -789,29 +707,6 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
return null;
}
@Override
public Location getFirstLocation() {
String selection = TrackPointsColumns._ID + "=(select min(" + TrackPointsColumns._ID + ") from "
+ TrackPointsColumns.TABLE_NAME + ")";
return findLocationBy(selection, null);
}
@Override
public Location getLastValidLocation() {
String selection = TrackPointsColumns._ID + "=(select max(" + TrackPointsColumns._ID + ") from "
+ TrackPointsColumns.TABLE_NAME + " WHERE " + TrackPointsColumns.LATITUDE + "<=90)";
return findLocationBy(selection, null);
}
@Override
public Location getLocation(long trackPointId) {
if (trackPointId < 0) {
return null;
}
return findLocationBy(
TrackPointsColumns._ID + "=?", new String[] { Long.toString(trackPointId) });
}
@Override
public Cursor getLocationsCursor(
long trackId, long startTrackPointId, int maxLocations, boolean descending) {
@@ -951,15 +846,26 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
}
return -1L;
}
@Override
public Location getLastTrackLocation(long trackId) {
if (trackId < 0) {
return null;
}
String selection = TrackPointsColumns._ID + "=(select max(" + TrackPointsColumns._ID
+ ") from " + TrackPointsColumns.TABLE_NAME + " WHERE " + TrackPointsColumns.TRACKID
+ "=?)";
String selection = TrackPointsColumns._ID + "=(select max(" + TrackPointsColumns._ID + ") from "
+ TrackPointsColumns.TABLE_NAME + " WHERE " + TrackPointsColumns.TRACKID + "=?)";
String[] selectionArgs = new String[] { Long.toString(trackId) };
return findLocationBy(selection, selectionArgs);
}
@Override
public Location getLastValidTrackLocation(long trackId) {
if (trackId < 0) {
return null;
}
String selection = TrackPointsColumns._ID + "=(select max(" + TrackPointsColumns._ID + ") from "
+ TrackPointsColumns.TABLE_NAME + " WHERE " + TrackPointsColumns.TRACKID + "=? AND "
+ TrackPointsColumns.LATITUDE + "<=90000000)";
String[] selectionArgs = new String[] { Long.toString(trackId) };
return findLocationBy(selection, selectionArgs);
}
@@ -1024,15 +930,10 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
}
}
@Override
public void fillLocation(Cursor cursor, Location location) {
fillLocation(cursor, new CachedTrackPointsIndexes(cursor), location);
}
@Override
public Location createLocation(Cursor cursor) {
Location location = new MyTracksLocation("");
fillLocation(cursor, location);
fillLocation(cursor, new CachedTrackPointsIndexes(cursor), location);
return location;
}