forked from upstream-mirrors/OpenTracks
Distance interval bugfixed: interval options are km/mi values.
This commit is contained in:
@@ -20,9 +20,13 @@ public class Distance {
|
|||||||
return of(distance_mile * UnitConversions.MI_TO_M);
|
return of(distance_mile * UnitConversions.MI_TO_M);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Distance ofKilometer(double distance_km) {
|
||||||
|
return of(distance_km * UnitConversions.KM_TO_M);
|
||||||
|
}
|
||||||
|
|
||||||
public static Distance one(boolean metricUnit) {
|
public static Distance one(boolean metricUnit) {
|
||||||
if (metricUnit) {
|
if (metricUnit) {
|
||||||
return Distance.of(1);
|
return Distance.ofKilometer(1);
|
||||||
} else {
|
} else {
|
||||||
return Distance.ofMile(1);
|
return Distance.ofMile(1);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ public class IntervalStatisticsModel extends AndroidViewModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
intervalsLiveData = new MutableLiveData<>();
|
intervalsLiveData = new MutableLiveData<>();
|
||||||
distanceInterval = interval.getValue();
|
distanceInterval = interval.getDistance(metricUnits);
|
||||||
loadIntervalStatistics();
|
loadIntervalStatistics();
|
||||||
}
|
}
|
||||||
return intervalsLiveData;
|
return intervalsLiveData;
|
||||||
@@ -73,7 +73,7 @@ public class IntervalStatisticsModel extends AndroidViewModel {
|
|||||||
interval = IntervalOption.OPTION_1;
|
interval = IntervalOption.OPTION_1;
|
||||||
}
|
}
|
||||||
|
|
||||||
distanceInterval = interval.getValue();
|
distanceInterval = interval.getDistance(metricUnits);
|
||||||
loadIntervalStatistics();
|
loadIntervalStatistics();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -91,19 +91,21 @@ public class IntervalStatisticsModel extends AndroidViewModel {
|
|||||||
OPTION_20(20),
|
OPTION_20(20),
|
||||||
OPTION_50(50);
|
OPTION_50(50);
|
||||||
|
|
||||||
private final Distance value;
|
private final int multiplier;
|
||||||
|
|
||||||
IntervalOption(int value) {
|
IntervalOption(int multiplier) {
|
||||||
this.value = Distance.of(value);
|
this.multiplier = multiplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Distance getValue() {
|
public Distance getDistance(boolean metricUnits) {
|
||||||
return value;
|
return Distance
|
||||||
|
.one(metricUnits)
|
||||||
|
.multipliedBy(multiplier);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "" + (int) value.toM(); //TODO Somehow IntervalsFragment relies on a parsable Integer.
|
return "" + multiplier; //TODO Somehow IntervalsFragment relies on a parsable Integer.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user