Class FitnessTopListAdapter
java.lang.Object
yearreview.app.data.sources.fitness.databse.FitnessTopListAdapter
- All Implemented Interfaces:
TopListAdapter
A
TopListAdapter
for the FitnessDatabase
that outputs the Activities with their Distances and Durations.- Author:
- ColdStone37
-
Field Summary
Modifier and TypeFieldDescriptionIterator for the Activities provided by theFitnessDatabase
.private Activity
Activity that is currently processed by the Adapter.private io.jenetics.jpx.Length
Distance of the currentActivity
that was already added to theTopListElement
.private Duration
Duration of the currentActivity
that was already added to theTopListElement
.private final FitnessDatabase
Database to adapt for theTopListGenerator
.private static final io.jenetics.jpx.Length
Constant that stores a Length of 0 meters sinceLength
does not provide one.private final Map<ActivityType,
TopListElement> Maps allActivityTypes
to theirTopListElements
. -
Constructor Summary
ConstructorDescriptionFitnessTopListAdapter
(FitnessDatabase database) Constructs a FitnessDistanceTopListAdapter from a Database. -
Method Summary
Modifier and TypeMethodDescriptionGets the TopListElements at a certain time.private static TopListElement
getNewTopListElement
(String name) Constructs a new TopListElement with a given name and Distance and Duration Values.
-
Field Details
-
LENGTH_ZERO
private static final io.jenetics.jpx.Length LENGTH_ZEROConstant that stores a Length of 0 meters sinceLength
does not provide one. -
database
Database to adapt for theTopListGenerator
. -
activityIterator
Iterator for the Activities provided by theFitnessDatabase
. -
currentActivity
Activity that is currently processed by the Adapter. -
currentActivityDistance
private io.jenetics.jpx.Length currentActivityDistanceDistance of the currentActivity
that was already added to theTopListElement
. -
currentActivityDuration
Duration of the currentActivity
that was already added to theTopListElement
. -
typeMap
Maps allActivityTypes
to theirTopListElements
.
-
-
Constructor Details
-
FitnessTopListAdapter
Constructs a FitnessDistanceTopListAdapter from a Database.- Parameters:
database
- database to adapt for theTopListGenerator
-
-
Method Details
-
getElements
Gets the TopListElements at a certain time. Iterates over the activity until one starts after t.- Specified by:
getElements
in interfaceTopListAdapter
- Parameters:
t
- time until which all values should be added up to- Returns:
- List of TopListElements with the Values summed up
-
getNewTopListElement
Constructs a new TopListElement with a given name and Distance and Duration Values.- Parameters:
name
- name to use for the TopListElement- Returns:
- new TopListElement
-