Make the weight dialog always display after enable calorie display. Change code style.

This commit is contained in:
youtaol
2013-08-27 17:06:28 +08:00
parent 57ca65e3b6
commit 10a3e18e7a
6 changed files with 44 additions and 65 deletions
@@ -20,7 +20,7 @@ import com.google.common.annotations.VisibleForTesting;
import android.location.Location;
/**
* Utils to calculate caloric expenditure.
* Utils to calculate calories.
*
* @author youtaol
*/
@@ -140,16 +140,16 @@ public class CalorieUtils {
}
/**
* Calculates the calories expenditure by cycling.
* Calculates the calories by cycling.
*
* @param start the start location
* @param stop the stop location
* @param grade the grade to calculate
* @param weight the weight of user, in kilogram
* @return the calories expenditure between the start and stop location.
* @return the calories between the start and stop location.
*/
@VisibleForTesting
static double calculateExpenditureCycling(Location start, Location stop, double grade, int weight) {
static double calculateCaloriesCycling(Location start, Location stop, double grade, int weight) {
// Gets duration in seconds
double duration = (double) (stop.getTime() - start.getTime()) * UnitConversions.MS_TO_S;
// Get speed in meters per second
@@ -162,17 +162,17 @@ public class CalorieUtils {
}
/**
* Calculates the calories expenditure by running or walking.
* Calculates the calories by running or walking.
*
* @param start the start location
* @param stop the stop location
* @param grade the grade to calculate
* @param weight the weight of user, in kilogram
* @return the calories expenditure between the start and stop location, in
* @return the calories between the start and stop location, in
* calories.
*/
@VisibleForTesting
static double calculateExpenditureFoot(Location start, Location stop, double grade, int weight) {
static double calculateCaloriesFoot(Location start, Location stop, double grade, int weight) {
// Get speed in meters per second
double averageSpeed = (start.getSpeed() + stop.getSpeed()) / 2.0;
// Get VO2 in mL/kg/min
@@ -203,21 +203,21 @@ public class CalorieUtils {
}
/**
* Calculates the calories expenditure between two locations.
* Calculates the calories between two locations.
*
* @param start the start location
* @param stop the stop location
* @param grade the grade to calculate
* @param weight the weight of user
* @param activityType can be foot or cycling
* @return the calories expenditure between the start and stop location.
* @return the calories between the start and stop location.
*/
public static double getCalories(Location start, Location stop, double grade, int weight,
ActivityType activityType) {
if (ActivityType.CYCLING == activityType) {
return calculateExpenditureCycling(start, stop, grade, weight);
return calculateCaloriesCycling(start, stop, grade, weight);
} else {
return calculateExpenditureFoot(start, stop, grade, weight);
return calculateCaloriesFoot(start, stop, grade, weight);
}
}
}
@@ -107,7 +107,6 @@ public class PreferencesUtils {
public static final String STATS_UNITS_DEFAULT = "METRIC";
public static final boolean STATS_SHOW_CALORIE_DEFAULT = false;
public static final int STATS_WEIGHT_DEFAULT = 65; // in kilogram
public static final int STATS_WEIGHT_DEFAULT_INVALID = -1;
// Track color
public static final String TRACK_COLOR_MODE_DEFAULT = "SINGLE";