forked from upstream-mirrors/OpenTracks
Update the TripStatisticsUpdater after change the activity type of current recording calorie. Using the activity type but calorie value to determine whether show activity set button or not.
This commit is contained in:
@@ -106,4 +106,11 @@ interface ITrackRecordingService {
|
||||
* return a Sensor.SensorState enum value.
|
||||
*/
|
||||
int getSensorState();
|
||||
|
||||
/**
|
||||
* Updates the calorie value.
|
||||
*
|
||||
* @param calorie new calorie value.
|
||||
*/
|
||||
void updateCalorie(double calorie);
|
||||
}
|
||||
|
||||
@@ -62,14 +62,8 @@ public class TripStatistics implements Parcelable {
|
||||
// The min and max grade seen on this trip.
|
||||
private final ExtremityMonitor gradeExtremities = new ExtremityMonitor();
|
||||
|
||||
/**
|
||||
* This value means the calorie value is invalid due to activity type is not
|
||||
* supported.
|
||||
*/
|
||||
public static final double CALORIE_UNDEFINED = -1.0;
|
||||
|
||||
// The calorie of current track.
|
||||
private double calorie = CALORIE_UNDEFINED;
|
||||
private double calorie = 0.0;
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
@@ -128,9 +122,7 @@ public class TripStatistics implements Parcelable {
|
||||
gradeExtremities.update(other.gradeExtremities.getMin());
|
||||
gradeExtremities.update(other.gradeExtremities.getMax());
|
||||
}
|
||||
if (other.calorie != CALORIE_UNDEFINED) {
|
||||
calorie += other.calorie;
|
||||
}
|
||||
calorie += other.calorie;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -585,11 +577,7 @@ public class TripStatistics implements Parcelable {
|
||||
* @param calorieAdded add the value to the total calorie
|
||||
*/
|
||||
public void addCalorie(double calorieAdded) {
|
||||
if (calorieAdded != CALORIE_UNDEFINED) {
|
||||
calorie = calorie == CALORIE_UNDEFINED ? calorieAdded : calorie + calorieAdded;
|
||||
} else {
|
||||
calorie = CALORIE_UNDEFINED;
|
||||
}
|
||||
calorie += calorieAdded;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user