added an incremental version number to prevent issues in case the Track format evolves in the future

This commit is contained in:
y20k 2017-01-18 10:44:16 +01:00
parent d38adb62d9
commit 0e94bdb9dd
2 changed files with 5 additions and 0 deletions

View file

@ -42,6 +42,7 @@ public class Track implements TrackbookKeys, Parcelable {
/* Main class variables */ /* Main class variables */
private final int mTrackFormatVersion;
private final List<WayPoint> mWayPoints; private final List<WayPoint> mWayPoints;
private float mTrackLength; private float mTrackLength;
private long mDuration; private long mDuration;
@ -52,6 +53,7 @@ public class Track implements TrackbookKeys, Parcelable {
/* Constructor */ /* Constructor */
public Track() { public Track() {
mTrackFormatVersion = CURRENT_TRACK_FORMAT_VERSION;
mWayPoints = new ArrayList<WayPoint>(); mWayPoints = new ArrayList<WayPoint>();
mTrackLength = 0f; mTrackLength = 0f;
mDuration = 0; mDuration = 0;
@ -63,6 +65,7 @@ public class Track implements TrackbookKeys, Parcelable {
/* Constructor used by CREATOR */ /* Constructor used by CREATOR */
protected Track(Parcel in) { protected Track(Parcel in) {
mTrackFormatVersion = in.readInt();
mWayPoints = in.createTypedArrayList(WayPoint.CREATOR); mWayPoints = in.createTypedArrayList(WayPoint.CREATOR);
mTrackLength = in.readFloat(); mTrackLength = in.readFloat();
mDuration = in.readLong(); mDuration = in.readLong();
@ -216,6 +219,7 @@ public class Track implements TrackbookKeys, Parcelable {
@Override @Override
public void writeToParcel(Parcel parcel, int flags) { public void writeToParcel(Parcel parcel, int flags) {
parcel.writeInt(mTrackFormatVersion);
parcel.writeTypedList(mWayPoints); parcel.writeTypedList(mWayPoints);
parcel.writeFloat(mTrackLength); parcel.writeFloat(mTrackLength);
parcel.writeLong(mDuration); parcel.writeLong(mDuration);

View file

@ -93,6 +93,7 @@ public interface TrackbookKeys {
int MAXIMUM_TRACK_FILES = 25; int MAXIMUM_TRACK_FILES = 25;
/* MISC */ /* MISC */
int CURRENT_TRACK_FORMAT_VERSION = 1; // incremental version number to prevent issues in case the Track format evolves
int REQUEST_CODE_ASK_MULTIPLE_PERMISSIONS = 124; int REQUEST_CODE_ASK_MULTIPLE_PERMISSIONS = 124;
int TRACKER_SERVICE_NOTIFICATION_ID = 1; int TRACKER_SERVICE_NOTIFICATION_ID = 1;
int INFOSHEET_CONTENT_ABOUT = 1; int INFOSHEET_CONTENT_ABOUT = 1;