#39 Consider ascent value when calculating calories

This commit is contained in:
jannis 2020-01-22 12:12:11 +01:00
parent e397bc502b
commit cde4eb5940
2 changed files with 8 additions and 2 deletions

View File

@ -54,6 +54,8 @@ class WorkoutSaver {
setRealElevation(); setRealElevation();
setAscentAndDescent(); setAscentAndDescent();
setCalories();
storeInDatabase(); storeInDatabase();
} }
@ -89,7 +91,6 @@ class WorkoutSaver {
workout.length= (int)length; workout.length= (int)length;
workout.avgSpeed= ((double) workout.length) / ((double) workout.duration / 1000); workout.avgSpeed= ((double) workout.length) / ((double) workout.duration / 1000);
workout.avgPace= ((double)workout.duration / 1000 / 60) / ((double) workout.length / 1000); workout.avgPace= ((double)workout.duration / 1000 / 60) / ((double) workout.length / 1000);
workout.calorie= CalorieCalculator.calculateCalories(workout, Instance.getInstance(context).userPreferences.getUserWeight());
} }
private void setTopSpeed(){ private void setTopSpeed(){
@ -177,6 +178,11 @@ class WorkoutSaver {
} }
private void setCalories() {
// Ascent has to be set previously
workout.calorie = CalorieCalculator.calculateCalories(workout, Instance.getInstance(context).userPreferences.getUserWeight());
}
private void storeInDatabase(){ private void storeInDatabase(){
db.workoutDao().insertWorkoutAndSamples(workout, samples.toArray(new WorkoutSample[0])); db.workoutDao().insertWorkoutAndSamples(workout, samples.toArray(new WorkoutSample[0]));
} }

View File

@ -25,7 +25,7 @@ public class CalorieCalculator {
/** /**
* *
* workoutType, duration and avgSpeed of workout have to be set * workoutType, duration, ascent and avgSpeed of workout have to be set
* *
* @param workout the workout * @param workout the workout
* @param weight the weight of the person in kilogram * @param weight the weight of the person in kilogram