forked from upstream-mirrors/OpenTracks
Introduced TrackPoint.Id.
This commit is contained in:
@@ -17,16 +17,23 @@ package de.dennisguse.opentracks.content.data;
|
||||
|
||||
import android.location.Location;
|
||||
import android.location.LocationManager;
|
||||
import android.os.Parcel;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* This class extends the standard Android location with extra information.
|
||||
*
|
||||
* @author Sandor Dornbush
|
||||
*/
|
||||
//TODO Merge constructors by use case; we have too many.
|
||||
public class TrackPoint {
|
||||
|
||||
private TrackPoint.Id id;
|
||||
|
||||
private final Location location;
|
||||
|
||||
private Float heartRate_bpm = null;
|
||||
@@ -92,8 +99,20 @@ public class TrackPoint {
|
||||
return new TrackPoint(resume);
|
||||
}
|
||||
|
||||
public @NonNull
|
||||
Location getLocation() {
|
||||
/**
|
||||
* May be null if the track was not loaded from the database.
|
||||
*/
|
||||
@Nullable
|
||||
public TrackPoint.Id getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(TrackPoint.Id id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Location getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
@@ -251,4 +270,41 @@ public class TrackPoint {
|
||||
public String toString() {
|
||||
return "time=" + getTime() + ": lat=" + getLatitude() + " lng=" + getLongitude() + " acc=" + getAccuracy();
|
||||
}
|
||||
|
||||
public static class Id {
|
||||
|
||||
private final long id;
|
||||
|
||||
public Id(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
protected Id(Parcel in) {
|
||||
id = in.readLong();
|
||||
}
|
||||
|
||||
//TOOD Limit visibility to TrackRecordingService / ContentProvider
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
TrackPoint.Id id1 = (TrackPoint.Id) o;
|
||||
return id == id1.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.valueOf(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user