mirror of
https://github.com/russok/FitoTrack.git
synced 2025-10-28 16:22:12 -07:00
#39 Consider ascent value when calculating calories
This commit is contained in:
parent
e397bc502b
commit
cde4eb5940
@ -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]));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user