Use the activity type of current track to calculate calorie.

This commit is contained in:
youtaol
2013-09-05 14:33:37 +08:00
parent e0375050d2
commit 7233137e93
14 changed files with 124 additions and 48 deletions
@@ -65,6 +65,13 @@ public class TripStatistics implements Parcelable {
// The calorie of current track.
private double calorie;
/**
* This value means the calorie value is invalid due to activity type is not
* supported.
*/
public static final double INVALID_CALORIE = -1;
/**
* Default constructor.
*/
@@ -532,7 +539,6 @@ public class TripStatistics implements Parcelable {
data.gradeExtremities.set(minGrade, maxGrade);
data.calorie = source.readDouble();
return data;
}
@@ -578,7 +584,9 @@ public class TripStatistics implements Parcelable {
* @param calorieAdded add the value to the total calorie
*/
public void addCalorie(double calorieAdded) {
this.calorie += calorieAdded;
if (calorieAdded != INVALID_CALORIE) {
this.calorie += calorieAdded;
}
}
/**
@@ -591,7 +599,7 @@ public class TripStatistics implements Parcelable {
}
/**
* Gets calories value.
* Gets calorie value.
*/
public double getCalorie() {
return calorie;