Add columns driveid, modifiedtime, and sharedwithme

Add tombstone when a track is deleted
This commit is contained in:
Jimmy Shih
2013-01-23 13:06:28 -08:00
parent 07cd1dcdbb
commit 77e6dc1b73
4 changed files with 217 additions and 83 deletions
@@ -85,6 +85,9 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
int mapIdIndex = cursor.getColumnIndexOrThrow(TracksColumns.MAPID);
int tableIdIndex = cursor.getColumnIndexOrThrow(TracksColumns.TABLEID);
int iconIndex = cursor.getColumnIndexOrThrow(TracksColumns.ICON);
int driveIdIndex = cursor.getColumnIndexOrThrow(TracksColumns.DRIVEID);
int modifiedTimeIndex = cursor.getColumnIndexOrThrow(TracksColumns.MODIFIEDTIME);
int sharedWithMeIndex = cursor.getColumnIndexOrThrow(TracksColumns.SHAREDWITHME);
Track track = new Track();
TripStatistics tripStatistics = track.getTripStatistics();
@@ -159,6 +162,15 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
if (!cursor.isNull(iconIndex)) {
track.setIcon(cursor.getString(iconIndex));
}
if (!cursor.isNull(driveIdIndex)) {
track.setDriveId(cursor.getString(driveIdIndex));
}
if (!cursor.isNull(modifiedTimeIndex)) {
track.setModifiedTime(cursor.getLong(modifiedTimeIndex));
}
if (!cursor.isNull(sharedWithMeIndex)) {
track.setSharedWithMe(cursor.getInt(sharedWithMeIndex) == 1);
}
return track;
}
@@ -302,6 +314,9 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
values.put(TracksColumns.MAPID, track.getMapId());
values.put(TracksColumns.TABLEID, track.getTableId());
values.put(TracksColumns.ICON, track.getIcon());
values.put(TracksColumns.DRIVEID, track.getDriveId());
values.put(TracksColumns.MODIFIEDTIME, track.getModifiedTime());
values.put(TracksColumns.SHAREDWITHME, track.isSharedWithMe());
return values;
}
@@ -32,19 +32,24 @@ import java.util.ArrayList;
*/
public class Track implements Parcelable {
private long id = -1;
private long id = -1L;
private String name = "";
private String description = "";
private String category = "";
private long startId = -1;
private long stopId = -1;
private long startId = -1L;
private long stopId = -1L;
// The number of location points (present even if the points themselves are
// not loaded)
/*
* The number of location points (present even if the points themselves are
* not loaded)
*/
private int numberOfPoints = 0;
private String mapId = "";
private String tableId = "";
private String icon = "";
private String driveId = "";
private long modifiedTime = -1L;
private boolean sharedWithMe = false;
private TripStatistics tripStatistics = new TripStatistics();
@@ -64,13 +69,16 @@ public class Track implements Parcelable {
mapId = in.readString();
tableId = in.readString();
icon = in.readString();
driveId = in.readString();
modifiedTime = in.readLong();
sharedWithMe = in.readByte() == 1;
ClassLoader classLoader = getClass().getClassLoader();
tripStatistics = in.readParcelable(classLoader);
for (int i = 0; i < numberOfPoints; ++i) {
Location loc = in.readParcelable(classLoader);
locations.add(loc);
Location location = in.readParcelable(classLoader);
locations.add(location);
}
}
@@ -91,6 +99,10 @@ public class Track implements Parcelable {
dest.writeString(mapId);
dest.writeString(tableId);
dest.writeString(icon);
dest.writeString(driveId);
dest.writeLong(modifiedTime);
dest.writeByte((byte) (sharedWithMe ? 1 : 0));
dest.writeParcelable(tripStatistics, 0);
for (int i = 0; i < numberOfPoints; ++i) {
dest.writeParcelable(locations.get(i), 0);
@@ -189,6 +201,30 @@ public class Track implements Parcelable {
this.icon = icon;
}
public String getDriveId() {
return driveId;
}
public void setDriveId(String driveId) {
this.driveId = driveId;
}
public long getModifiedTime() {
return modifiedTime;
}
public void setModifiedTime(long modifiedTime) {
this.modifiedTime = modifiedTime;
}
public boolean isSharedWithMe() {
return sharedWithMe;
}
public void setSharedWithMe(boolean sharedWithMe) {
this.sharedWithMe = sharedWithMe;
}
public TripStatistics getTripStatistics() {
return tripStatistics;
}
@@ -197,8 +233,8 @@ public class Track implements Parcelable {
this.tripStatistics = tripStatistics;
}
public void addLocation(Location l) {
locations.add(l);
public void addLocation(Location location) {
locations.add(location);
}
public ArrayList<Location> getLocations() {
@@ -66,7 +66,9 @@ public interface TracksColumns extends BaseColumns {
public static final String MINLON = "minlon"; // minimum longitude
public static final String MAXLON = "maxlon"; // maximum longitude
public static final String AVGSPEED = "avgspeed"; // average speed
public static final String AVGMOVINGSPEED = "avgmovingspeed"; // average moving speed
// average moving speed
public static final String AVGMOVINGSPEED = "avgmovingspeed";
public static final String MAXSPEED = "maxspeed"; // maximum speed
public static final String MINELEVATION = "minelevation"; // minimum elevation
public static final String MAXELEVATION = "maxelevation"; // maximum elevation
@@ -76,69 +78,78 @@ public interface TracksColumns extends BaseColumns {
public static final String MAPID = "mapid"; // Google Maps id
public static final String TABLEID = "tableid"; // Google Fusion Tables id
public static final String ICON = "icon"; // track activity type icon
public static final String CREATE_TABLE = "CREATE TABLE " + TABLE_NAME + " ("
+ _ID + " INTEGER PRIMARY KEY AUTOINCREMENT, "
+ NAME + " STRING, "
+ DESCRIPTION + " STRING, "
+ CATEGORY + " STRING, "
+ STARTID + " INTEGER, "
+ STOPID + " INTEGER, "
+ STARTTIME + " INTEGER, "
+ STOPTIME + " INTEGER, "
+ NUMPOINTS + " INTEGER, "
+ TOTALDISTANCE + " FLOAT, "
+ TOTALTIME + " INTEGER, "
+ MOVINGTIME + " INTEGER, "
+ MINLAT + " INTEGER, "
+ MAXLAT + " INTEGER, "
+ MINLON + " INTEGER, "
+ MAXLON + " INTEGER, "
+ AVGSPEED + " FLOAT, "
+ AVGMOVINGSPEED + " FLOAT, "
+ MAXSPEED + " FLOAT, "
+ MINELEVATION + " FLOAT, "
+ MAXELEVATION + " FLOAT, "
+ ELEVATIONGAIN + " FLOAT, "
+ MINGRADE + " FLOAT, "
+ MAXGRADE + " FLOAT, "
+ MAPID + " STRING, "
+ TABLEID + " STRING, "
+ ICON + " STRING"
+ ");";
public static final String DRIVEID = "driveid"; // Google Drive file id
public static final String[] COLUMNS = {
_ID,
NAME,
DESCRIPTION,
CATEGORY,
STARTID,
STOPID,
STARTTIME,
STOPTIME,
NUMPOINTS,
TOTALDISTANCE,
TOTALTIME,
MOVINGTIME,
MINLAT,
MAXLAT,
MINLON,
MAXLON,
AVGSPEED,
AVGMOVINGSPEED,
MAXSPEED,
MINELEVATION,
MAXELEVATION,
ELEVATIONGAIN,
MINGRADE,
MAXGRADE,
MAPID,
TABLEID,
ICON
};
// Google drive file modified time
public static final String MODIFIEDTIME = "modifiedtime";
public static final byte[] COLUMN_TYPES = {
ContentTypeIds.LONG_TYPE_ID, // id
// 1 if the Google Drive file is from the "Shared with me" directory
public static final String SHAREDWITHME = "sharedwithme";
public static final String CREATE_TABLE = "CREATE TABLE " + TABLE_NAME + " (" // table
+ _ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " // id
+ NAME + " STRING, " // name
+ DESCRIPTION + " STRING, " // description
+ CATEGORY + " STRING, " // category
+ STARTID + " INTEGER, " // start id
+ STOPID + " INTEGER, " // stop id
+ STARTTIME + " INTEGER, " // start time
+ STOPTIME + " INTEGER, " // stop time
+ NUMPOINTS + " INTEGER, " // num points
+ TOTALDISTANCE + " FLOAT, " // total distance
+ TOTALTIME + " INTEGER, " // total time
+ MOVINGTIME + " INTEGER, " // moving time
+ MINLAT + " INTEGER, " // min latitude
+ MAXLAT + " INTEGER, " // max latitude
+ MINLON + " INTEGER, " // min longitude
+ MAXLON + " INTEGER, " // max longitude
+ AVGSPEED + " FLOAT, " // average speed
+ AVGMOVINGSPEED + " FLOAT, " // average moving speed
+ MAXSPEED + " FLOAT, " // max speed
+ MINELEVATION + " FLOAT, " // min elevation
+ MAXELEVATION + " FLOAT, " // max elevation
+ ELEVATIONGAIN + " FLOAT, " // elevation gain
+ MINGRADE + " FLOAT, " // min grade
+ MAXGRADE + " FLOAT, " // max grade
+ MAPID + " STRING, " // map id
+ TABLEID + " STRING, " // table id
+ ICON + " STRING, " // icon
+ DRIVEID + " STRING, " // drive id
+ MODIFIEDTIME + " INTEGER, " // modified time
+ SHAREDWITHME + " INTEGER" + ");"; // shared with me
public static final String[] COLUMNS = { _ID, // id
NAME, // name
DESCRIPTION, // description
CATEGORY, // category
STARTID, // start id
STOPID, // stop id
STARTTIME, // start time
STOPTIME, // stop time
NUMPOINTS, // num points
TOTALDISTANCE, // total distance
TOTALTIME, // total time
MOVINGTIME, // moving time
MINLAT, // min latitude
MAXLAT, // max latitude
MINLON, // min longitude
MAXLON, // max longitude
AVGSPEED, // average speed
AVGMOVINGSPEED, // average moving speed
MAXSPEED, // max speed
MINELEVATION, // min elevation
MAXELEVATION, // max elevation
ELEVATIONGAIN, // elevation gain
MINGRADE, // min grade
MAXGRADE, // max grade
MAPID, // map id
TABLEID, // table id
ICON, // icon
DRIVEID, // drive id
MODIFIEDTIME, // modified time
SHAREDWITHME }; // shared with me
public static final byte[] COLUMN_TYPES = { ContentTypeIds.LONG_TYPE_ID, // id
ContentTypeIds.STRING_TYPE_ID, // name
ContentTypeIds.STRING_TYPE_ID, // description
ContentTypeIds.STRING_TYPE_ID, // category
@@ -164,6 +175,9 @@ public interface TracksColumns extends BaseColumns {
ContentTypeIds.FLOAT_TYPE_ID, // max grade
ContentTypeIds.STRING_TYPE_ID, // map id
ContentTypeIds.STRING_TYPE_ID, // table id
ContentTypeIds.STRING_TYPE_ID // icon
};
ContentTypeIds.STRING_TYPE_ID, // icon
ContentTypeIds.STRING_TYPE_ID, // drive id
ContentTypeIds.LONG_TYPE_ID, // modified time
ContentTypeIds.BOOLEAN_TYPE_ID // shared with me
};
}