forked from upstream-mirrors/OpenTracks
Add a category icon in Track.java and TracksColumns.java.
Clean up Track.java and TracksColumns.java.
This commit is contained in:
+2
-2
@@ -92,7 +92,7 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
|
||||
@Override
|
||||
public ContentValues createContentValues(Track track) {
|
||||
ContentValues values = new ContentValues();
|
||||
TripStatistics stats = track.getStatistics();
|
||||
TripStatistics stats = track.getTripStatistics();
|
||||
|
||||
// Values id < 0 indicate no id is available:
|
||||
if (track.getId() >= 0) {
|
||||
@@ -297,7 +297,7 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
|
||||
int idxMaxGrade = cursor.getColumnIndexOrThrow(TracksColumns.MAXGRADE);
|
||||
|
||||
Track track = new Track();
|
||||
TripStatistics stats = track.getStatistics();
|
||||
TripStatistics stats = track.getTripStatistics();
|
||||
if (!cursor.isNull(idxId)) {
|
||||
track.setId(cursor.getLong(idxId));
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
|
||||
package com.google.android.apps.mytracks.content;
|
||||
|
||||
import com.google.android.apps.mytracks.stats.TripStatistics;
|
||||
@@ -24,98 +25,89 @@ import android.os.Parcelable;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* A class representing a (GPS) Track.
|
||||
*
|
||||
* TODO: hashCode and equals
|
||||
*
|
||||
* A track.
|
||||
*
|
||||
* @author Leif Hendrik Wilden
|
||||
* @author Rodrigo Damazio
|
||||
*/
|
||||
public class Track implements Parcelable {
|
||||
|
||||
/**
|
||||
* Creator for a Track object.
|
||||
*/
|
||||
public static class Creator implements Parcelable.Creator<Track> {
|
||||
|
||||
public Track createFromParcel(Parcel source) {
|
||||
ClassLoader classLoader = getClass().getClassLoader();
|
||||
Track track = new Track();
|
||||
track.id = source.readLong();
|
||||
track.name = source.readString();
|
||||
track.description = source.readString();
|
||||
track.mapId = source.readString();
|
||||
track.category = source.readString();
|
||||
track.startId = source.readLong();
|
||||
track.stopId = source.readLong();
|
||||
track.stats = source.readParcelable(classLoader);
|
||||
|
||||
track.numberOfPoints = source.readInt();
|
||||
for (int i = 0; i < track.numberOfPoints; ++i) {
|
||||
Location loc = source.readParcelable(classLoader);
|
||||
track.locations.add(loc);
|
||||
}
|
||||
|
||||
track.tableId = source.readString();
|
||||
return track;
|
||||
}
|
||||
|
||||
public Track[] newArray(int size) {
|
||||
return new Track[size];
|
||||
}
|
||||
}
|
||||
|
||||
public static final Creator CREATOR = new Creator();
|
||||
|
||||
/**
|
||||
* The track points (which may not have been loaded).
|
||||
*/
|
||||
private ArrayList<Location> locations = new ArrayList<Location>();
|
||||
|
||||
/**
|
||||
* The number of location points (present even if the points themselves were
|
||||
* not loaded).
|
||||
*/
|
||||
private int numberOfPoints = 0;
|
||||
|
||||
private long id = -1;
|
||||
private String name = "";
|
||||
private String description = "";
|
||||
private String mapId = "";
|
||||
private String tableId = "";
|
||||
private String category = "";
|
||||
private String categoryIcon = "";
|
||||
private long startId = -1;
|
||||
private long stopId = -1;
|
||||
private String category = "";
|
||||
|
||||
private TripStatistics stats = new TripStatistics();
|
||||
// The number of location points (present even if the points themselves are
|
||||
// not loaded)
|
||||
private int numberOfPoints = 0;
|
||||
private String mapId = "";
|
||||
private String tableId = "";
|
||||
|
||||
public Track() {
|
||||
private TripStatistics tripStatistics = new TripStatistics();
|
||||
|
||||
// Location points (which may not have been loaded)
|
||||
private ArrayList<Location> locations = new ArrayList<Location>();
|
||||
|
||||
public Track() {}
|
||||
|
||||
private Track(Parcel in) {
|
||||
id = in.readLong();
|
||||
name = in.readString();
|
||||
description = in.readString();
|
||||
category = in.readString();
|
||||
categoryIcon = in.readString();
|
||||
startId = in.readLong();
|
||||
stopId = in.readLong();
|
||||
numberOfPoints = in.readInt();
|
||||
mapId = in.readString();
|
||||
tableId = in.readString();
|
||||
|
||||
ClassLoader classLoader = getClass().getClassLoader();
|
||||
for (int i = 0; i < numberOfPoints; ++i) {
|
||||
Location loc = in.readParcelable(classLoader);
|
||||
locations.add(loc);
|
||||
}
|
||||
|
||||
tripStatistics = in.readParcelable(classLoader);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeLong(id);
|
||||
dest.writeString(name);
|
||||
dest.writeString(description);
|
||||
dest.writeString(mapId);
|
||||
dest.writeString(category);
|
||||
dest.writeString(categoryIcon);
|
||||
dest.writeLong(startId);
|
||||
dest.writeLong(stopId);
|
||||
dest.writeParcelable(stats, 0);
|
||||
|
||||
dest.writeInt(numberOfPoints);
|
||||
dest.writeString(mapId);
|
||||
dest.writeString(tableId);
|
||||
for (int i = 0; i < numberOfPoints; ++i) {
|
||||
dest.writeParcelable(locations.get(i), 0);
|
||||
}
|
||||
|
||||
dest.writeString(tableId);
|
||||
dest.writeParcelable(tripStatistics, 0);
|
||||
}
|
||||
|
||||
// Getters and setters:
|
||||
//---------------------
|
||||
public static final Parcelable.Creator<Track> CREATOR = new Parcelable.Creator<Track>() {
|
||||
@Override
|
||||
public Track createFromParcel(Parcel in) {
|
||||
return new Track(in);
|
||||
}
|
||||
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public Track[] newArray(int size) {
|
||||
return new Track[size];
|
||||
}
|
||||
};
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
@@ -133,6 +125,30 @@ public class Track implements Parcelable {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getCategory() {
|
||||
return category;
|
||||
}
|
||||
|
||||
public void setCategory(String category) {
|
||||
this.category = category;
|
||||
}
|
||||
|
||||
public String getCategoryIcon() {
|
||||
return categoryIcon;
|
||||
}
|
||||
|
||||
public void setCategoryIcon(String categoryIcon) {
|
||||
this.categoryIcon = categoryIcon;
|
||||
}
|
||||
|
||||
public long getStartId() {
|
||||
return startId;
|
||||
}
|
||||
@@ -149,12 +165,12 @@ public class Track implements Parcelable {
|
||||
this.stopId = stopId;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
public int getNumberOfPoints() {
|
||||
return numberOfPoints;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
public void setNumberOfPoints(int numberOfPoints) {
|
||||
this.numberOfPoints = numberOfPoints;
|
||||
}
|
||||
|
||||
public String getMapId() {
|
||||
@@ -173,22 +189,6 @@ public class Track implements Parcelable {
|
||||
this.tableId = tableId;
|
||||
}
|
||||
|
||||
public String getCategory() {
|
||||
return category;
|
||||
}
|
||||
|
||||
public void setCategory(String category) {
|
||||
this.category = category;
|
||||
}
|
||||
|
||||
public int getNumberOfPoints() {
|
||||
return numberOfPoints;
|
||||
}
|
||||
|
||||
public void setNumberOfPoints(int numberOfPoints) {
|
||||
this.numberOfPoints = numberOfPoints;
|
||||
}
|
||||
|
||||
public void addLocation(Location l) {
|
||||
locations.add(l);
|
||||
}
|
||||
@@ -201,11 +201,11 @@ public class Track implements Parcelable {
|
||||
this.locations = locations;
|
||||
}
|
||||
|
||||
public TripStatistics getStatistics() {
|
||||
return stats;
|
||||
public TripStatistics getTripStatistics() {
|
||||
return tripStatistics;
|
||||
}
|
||||
|
||||
public void setStatistics(TripStatistics stats) {
|
||||
this.stats = stats;
|
||||
public void setTripStatistics(TripStatistics tripStatistics) {
|
||||
this.tripStatistics = tripStatistics;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,51 +13,66 @@
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
|
||||
package com.google.android.apps.mytracks.content;
|
||||
|
||||
import android.net.Uri;
|
||||
import android.provider.BaseColumns;
|
||||
|
||||
/**
|
||||
* Defines the URI for the tracks provider and the available column names
|
||||
* and content types.
|
||||
*
|
||||
* Constants for track table.
|
||||
*
|
||||
* @author Leif Hendrik Wilden
|
||||
*/
|
||||
public interface TracksColumns extends BaseColumns {
|
||||
|
||||
public static final Uri CONTENT_URI =
|
||||
Uri.parse("content://com.google.android.maps.mytracks/tracks");
|
||||
public static final String CONTENT_TYPE =
|
||||
"vnd.android.cursor.dir/vnd.google.track";
|
||||
public static final String CONTENT_ITEMTYPE =
|
||||
"vnd.android.cursor.item/vnd.google.track";
|
||||
/**
|
||||
* Tracks provider uri.
|
||||
*/
|
||||
public static final Uri CONTENT_URI = Uri.parse(
|
||||
"content://com.google.android.maps.mytracks/tracks");
|
||||
|
||||
/**
|
||||
* Track content type.
|
||||
*/
|
||||
public static final String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.google.track";
|
||||
|
||||
/**
|
||||
* Track id content type.
|
||||
*/
|
||||
public static final String CONTENT_ITEMTYPE = "vnd.android.cursor.item/vnd.google.track";
|
||||
|
||||
/**
|
||||
* Tracks table default sort order.
|
||||
*/
|
||||
public static final String DEFAULT_SORT_ORDER = "_id";
|
||||
|
||||
/* All columns */
|
||||
public static final String NAME = "name";
|
||||
public static final String DESCRIPTION = "description";
|
||||
public static final String CATEGORY = "category";
|
||||
public static final String STARTID = "startid";
|
||||
public static final String STOPID = "stopid";
|
||||
public static final String STARTTIME = "starttime";
|
||||
public static final String STOPTIME = "stoptime";
|
||||
public static final String NUMPOINTS = "numpoints";
|
||||
public static final String TOTALDISTANCE = "totaldistance";
|
||||
public static final String TOTALTIME = "totaltime";
|
||||
public static final String MOVINGTIME = "movingtime";
|
||||
public static final String AVGSPEED = "avgspeed";
|
||||
public static final String AVGMOVINGSPEED = "avgmovingspeed";
|
||||
public static final String MAXSPEED = "maxspeed";
|
||||
public static final String MINELEVATION = "minelevation";
|
||||
public static final String MAXELEVATION = "maxelevation";
|
||||
public static final String ELEVATIONGAIN = "elevationgain";
|
||||
public static final String MINGRADE = "mingrade";
|
||||
public static final String MAXGRADE = "maxgrade";
|
||||
public static final String MINLAT = "minlat";
|
||||
public static final String MAXLAT = "maxlat";
|
||||
public static final String MINLON = "minlon";
|
||||
public static final String MAXLON = "maxlon";
|
||||
public static final String MAPID = "mapid";
|
||||
public static final String TABLEID = "tableid";
|
||||
// Tracks table columns
|
||||
public static final String NAME = "name"; // track name
|
||||
public static final String DESCRIPTION = "description"; // track description
|
||||
public static final String CATEGORY = "category"; // track activity type
|
||||
public static final String CATEGORY_ICON = "categoryicon"; // track activity type icon
|
||||
public static final String STARTID = "startid"; // first track point id
|
||||
public static final String STOPID = "stopid"; // last track point id
|
||||
public static final String STARTTIME = "starttime"; // track start time
|
||||
public static final String STOPTIME = "stoptime"; // track stop time
|
||||
public static final String NUMPOINTS = "numpoints"; // number of track points
|
||||
public static final String TOTALDISTANCE = "totaldistance"; // total distance
|
||||
public static final String TOTALTIME = "totaltime"; // total time
|
||||
public static final String MOVINGTIME = "movingtime"; // moving time
|
||||
public static final String AVGSPEED = "avgspeed"; // average speed
|
||||
public static final String AVGMOVINGSPEED = "avgmovingspeed"; // average
|
||||
// moving speed
|
||||
public static final String MAXSPEED = "maxspeed"; // maximum speed
|
||||
public static final String MINELEVATION = "minelevation"; // minimum elevation
|
||||
public static final String MAXELEVATION = "maxelevation"; // maximum elevation
|
||||
public static final String ELEVATIONGAIN = "elevationgain"; // elevation gain
|
||||
public static final String MINGRADE = "mingrade"; // minimum grade
|
||||
public static final String MAXGRADE = "maxgrade"; // maximum grade
|
||||
public static final String MINLAT = "minlat"; // minimum latitude
|
||||
public static final String MAXLAT = "maxlat"; // maximum latitude
|
||||
public static final String MINLON = "minlon"; // minimum longitude
|
||||
public static final String MAXLON = "maxlon"; // maximum longitude
|
||||
public static final String MAPID = "mapid"; // Google Maps id
|
||||
public static final String TABLEID = "tableid"; // Google Fusion Tables id
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user