From 110754346304069132e9eb1e8cb94390ee0b7ad6 Mon Sep 17 00:00:00 2001 From: youtaol Date: Tue, 10 Sep 2013 16:16:25 +0800 Subject: [PATCH] Make the default calorie to invalid. Fix an error while calculating the cycling calorie. --- .../google/android/apps/mytracks/util/CalorieUtils.java | 6 +++--- .../google/android/apps/mytracks/stats/TripStatistics.java | 7 +++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/MyTracks/src/com/google/android/apps/mytracks/util/CalorieUtils.java b/MyTracks/src/com/google/android/apps/mytracks/util/CalorieUtils.java index e78cc399a..32d557d66 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/util/CalorieUtils.java +++ b/MyTracks/src/com/google/android/apps/mytracks/util/CalorieUtils.java @@ -134,15 +134,15 @@ public class CalorieUtils { * @param grade the grade to calculate * @param weight of rider plus bike, in kilogram * @param timeUsed how many times used in second - * @return the power value watts(Joule/second). + * @return the calorie value in kcal. */ @VisibleForTesting static double calculateCyclingCalorie(double speed, double grade, int weight, double timeUsed) { // Get the Power, the unit is Watt (Joule/second) double power = earthGravity * weight * speed * (K1 + grade) + K2 * (speed * speed * speed); - // Get the calories - return power * timeUsed / UnitConversions.KCAL_TO_J; + // Get the calories in kcal + return power * timeUsed / UnitConversions.KCAL_TO_J / 1000 ; } /** diff --git a/MyTracksLib/src/com/google/android/apps/mytracks/stats/TripStatistics.java b/MyTracksLib/src/com/google/android/apps/mytracks/stats/TripStatistics.java index 80aadb902..c5e80c1b4 100644 --- a/MyTracksLib/src/com/google/android/apps/mytracks/stats/TripStatistics.java +++ b/MyTracksLib/src/com/google/android/apps/mytracks/stats/TripStatistics.java @@ -62,16 +62,15 @@ public class TripStatistics implements Parcelable { // The min and max grade seen on this trip. 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 * supported. */ public static final double INVALID_CALORIE = -1.0; + // The calorie of current track. + private double calorie = INVALID_CALORIE; + /** * Default constructor. */