Class Activity
java.lang.Object
yearreview.app.data.sources.fitness.databse.Activity
- All Implemented Interfaces:
Comparable<Activity>
Internal representation of a fitness-activity, stored inside the
FitnessDatabase
.- Author:
- ColdStone37
-
Field Summary
Modifier and TypeFieldDescriptionfinal io.jenetics.jpx.Length
Distance of the activity.final Duration
Duration of the activity.final String
Name of the activity.final Instant
Start time of the activity.final io.jenetics.jpx.GPX
GPX-track of the activity if available.final ActivityType
Type of the activity. -
Constructor Summary
ConstructorDescriptionActivity
(String name, ActivityType type, io.jenetics.jpx.GPX track) Constructor for an activity that gets timing values from the GPX-track.Activity
(String name, ActivityType type, Instant time, Duration duration, io.jenetics.jpx.Length distance) Constructor for an activity without a GPX-track.Activity
(String name, ActivityType type, Instant time, Duration duration, io.jenetics.jpx.Length distance, io.jenetics.jpx.GPX track) Constructor for an activity with all values. -
Method Summary
Modifier and TypeMethodDescriptionint
Compares one activity to another by comparing the starting times.io.jenetics.jpx.Length
Gets the Distance of the activity until a certain time.private static Instant
getTrackEnd
(io.jenetics.jpx.GPX track) Gets the ending time of a GPX-track by finding the time of the lastWayPoint
.private static io.jenetics.jpx.Length
getTrackLength
(io.jenetics.jpx.GPX track) Gets the Length of a GPX-track by summing up the distances between the Waypoints.private io.jenetics.jpx.Length
Calculates the length of a GPX-track until a certain time.private static Instant
getTrackStart
(io.jenetics.jpx.GPX track) Gets the starting time of a GPX-track by finding the time of the firstWayPoint
.toString()
Custom toString()-function for activities.
-
Field Details
-
name
Name of the activity. -
type
Type of the activity. -
track
public final io.jenetics.jpx.GPX trackGPX-track of the activity if available. -
time
Start time of the activity. -
duration
Duration of the activity. -
distance
public final io.jenetics.jpx.Length distanceDistance of the activity. (Might not make sense in some cases)
-
-
Constructor Details
-
Activity
Constructor for an activity that gets timing values from the GPX-track.- Parameters:
name
- name of the activitytype
- type of the activitytrack
- GPX-Track used to gather the rest of the needed data
-
Activity
public Activity(String name, ActivityType type, Instant time, Duration duration, io.jenetics.jpx.Length distance, io.jenetics.jpx.GPX track) Constructor for an activity with all values.- Parameters:
name
- name of the activitytype
- type of the activitytime
- starting time of the activityduration
- duration of the activitydistance
- distance of the activity (might not make sense in some cases)track
- GPX-track of the activity
-
Activity
public Activity(String name, ActivityType type, Instant time, Duration duration, io.jenetics.jpx.Length distance) Constructor for an activity without a GPX-track.- Parameters:
name
- name of the activitytype
- type of the activitytime
- starting time of the activityduration
- duration of the activitydistance
- distance of the activity (might not make sense in some cases)
-
-
Method Details
-
getTrackLength
private static io.jenetics.jpx.Length getTrackLength(io.jenetics.jpx.GPX track) Gets the Length of a GPX-track by summing up the distances between the Waypoints.- Parameters:
track
- GPX-track to calculate the length of- Returns:
- total Length of the passed track
-
getTrackStart
Gets the starting time of a GPX-track by finding the time of the firstWayPoint
.- Parameters:
track
- GPX-track to find the starting time of- Returns:
- starting time if available otherwise null
-
getTrackEnd
Gets the ending time of a GPX-track by finding the time of the lastWayPoint
.- Parameters:
track
- GPX-track to find the ending time of- Returns:
- ending time if available otherwise null
-
getDistanceUntil
Gets the Distance of the activity until a certain time. Clamps values before the starting time of the activity to 0 and values after the activity to the length of the activity.- Parameters:
t
- time until the Length of the track should be calculated- Returns:
- Length of the track before t
-
getTrackLengthUntil
Calculates the length of a GPX-track until a certain time.- Parameters:
t
- time until the Length of the track should be summed up to- Returns:
- Length of track before t
-
toString
Custom toString()-function for activities. -
compareTo
Compares one activity to another by comparing the starting times.- Specified by:
compareTo
in interfaceComparable<Activity>
- Parameters:
other
- Activity to compare against- Returns:
- negative value if this activity is before other, positive if it is after other
-