java.lang.Object
yearreview.app.data.sources.fitness.databse.Activity
All Implemented Interfaces:
Comparable<Activity>

public class Activity extends Object implements Comparable<Activity>
Internal representation of a fitness-activity, stored inside the FitnessDatabase.
Author:
ColdStone37
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final 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.
    Type of the activity.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Activity(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 Type
    Method
    Description
    int
    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 last WayPoint.
    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 first WayPoint.
    Custom toString()-function for activities.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • name

      public final String name
      Name of the activity.
    • type

      public final ActivityType type
      Type of the activity.
    • track

      public final io.jenetics.jpx.GPX track
      GPX-track of the activity if available.
    • time

      public final Instant time
      Start time of the activity.
    • duration

      public final Duration duration
      Duration of the activity.
    • distance

      public final io.jenetics.jpx.Length distance
      Distance of the activity. (Might not make sense in some cases)
  • Constructor Details

    • Activity

      public Activity(String name, ActivityType type, io.jenetics.jpx.GPX track)
      Constructor for an activity that gets timing values from the GPX-track.
      Parameters:
      name - name of the activity
      type - type of the activity
      track - 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 activity
      type - type of the activity
      time - starting time of the activity
      duration - duration of the activity
      distance - 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 activity
      type - type of the activity
      time - starting time of the activity
      duration - duration of the activity
      distance - 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

      private static Instant getTrackStart(io.jenetics.jpx.GPX track)
      Gets the starting time of a GPX-track by finding the time of the first WayPoint.
      Parameters:
      track - GPX-track to find the starting time of
      Returns:
      starting time if available otherwise null
    • getTrackEnd

      private static Instant getTrackEnd(io.jenetics.jpx.GPX track)
      Gets the ending time of a GPX-track by finding the time of the last WayPoint.
      Parameters:
      track - GPX-track to find the ending time of
      Returns:
      ending time if available otherwise null
    • getDistanceUntil

      public io.jenetics.jpx.Length getDistanceUntil(Instant t)
      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

      private io.jenetics.jpx.Length getTrackLengthUntil(Instant t)
      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

      public String toString()
      Custom toString()-function for activities.
      Overrides:
      toString in class Object
      Returns:
      String with name of the activity, the starting and ending times and the distance
    • compareTo

      public int compareTo(Activity other)
      Compares one activity to another by comparing the starting times.
      Specified by:
      compareTo in interface Comparable<Activity>
      Parameters:
      other - Activity to compare against
      Returns:
      negative value if this activity is before other, positive if it is after other