Make the default calorie to invalid. Fix an error while calculating the cycling calorie.

This commit is contained in:
youtaol
2013-09-10 16:16:25 +08:00
parent 02587dc27e
commit 1107543463
2 changed files with 6 additions and 7 deletions
@@ -134,15 +134,15 @@ public class CalorieUtils {
* @param grade the grade to calculate * @param grade the grade to calculate
* @param weight of rider plus bike, in kilogram * @param weight of rider plus bike, in kilogram
* @param timeUsed how many times used in second * @param timeUsed how many times used in second
* @return the power value watts(Joule/second). * @return the calorie value in kcal.
*/ */
@VisibleForTesting @VisibleForTesting
static double calculateCyclingCalorie(double speed, double grade, int weight, double timeUsed) { static double calculateCyclingCalorie(double speed, double grade, int weight, double timeUsed) {
// Get the Power, the unit is Watt (Joule/second) // Get the Power, the unit is Watt (Joule/second)
double power = earthGravity * weight * speed * (K1 + grade) + K2 * (speed * speed * speed); double power = earthGravity * weight * speed * (K1 + grade) + K2 * (speed * speed * speed);
// Get the calories // Get the calories in kcal
return power * timeUsed / UnitConversions.KCAL_TO_J; return power * timeUsed / UnitConversions.KCAL_TO_J / 1000 ;
} }
/** /**
@@ -62,16 +62,15 @@ public class TripStatistics implements Parcelable {
// The min and max grade seen on this trip. // The min and max grade seen on this trip.
private final ExtremityMonitor gradeExtremities = new ExtremityMonitor(); private final ExtremityMonitor gradeExtremities = new ExtremityMonitor();
// The calorie of current track.
private double calorie;
/** /**
* This value means the calorie value is invalid due to activity type is not * This value means the calorie value is invalid due to activity type is not
* supported. * supported.
*/ */
public static final double INVALID_CALORIE = -1.0; public static final double INVALID_CALORIE = -1.0;
// The calorie of current track.
private double calorie = INVALID_CALORIE;
/** /**
* Default constructor. * Default constructor.
*/ */