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
FieldsModifier and TypeFieldDescriptionIterator for the Activities provided by theFitnessDatabase.private ActivityActivity that is currently processed by the Adapter.private io.jenetics.jpx.LengthDistance of the currentActivitythat was already added to theTopListElement.private DurationDuration of the currentActivitythat was already added to theTopListElement.private final FitnessDatabaseDatabase to adapt for theTopListGenerator.private static final io.jenetics.jpx.LengthConstant that stores a Length of 0 meters sinceLengthdoes not provide one.private final Map<ActivityType,TopListElement> Maps allActivityTypesto theirTopListElements. -
Constructor Summary
ConstructorsConstructorDescriptionFitnessTopListAdapter(FitnessDatabase database) Constructs a FitnessDistanceTopListAdapter from a Database. -
Method Summary
Modifier and TypeMethodDescriptionGets the TopListElements at a certain time.private static TopListElementgetNewTopListElement(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 sinceLengthdoes 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 currentActivitythat was already added to theTopListElement. -
currentActivityDuration
Duration of the currentActivitythat was already added to theTopListElement. -
typeMap
Maps allActivityTypesto 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:
getElementsin 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
-