forked from upstream-mirrors/OpenTracks
Bugfix: running sensor's data should be null if not connected.
Fixes #950.
This commit is contained in:
@@ -57,22 +57,24 @@ public final class SensorDataRunning extends SensorData<SensorDataRunning.Data>
|
|||||||
@Override
|
@Override
|
||||||
protected Data getNoneValue() {
|
protected Data getNoneValue() {
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
return new Data(Speed.zero(), 0f, ((Data) value).distance);
|
return new Data(Speed.zero(), 0f, value.distance);
|
||||||
} else {
|
} else {
|
||||||
return new Data(Speed.zero(), 0f, Distance.of(0));
|
return new Data(Speed.zero(), 0f, Distance.of(0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void compute(SensorDataRunning previous) {
|
public void compute(SensorDataRunning previous) {
|
||||||
Distance overallDistance = null;
|
if (speed != null && hasTotalDistance()) {
|
||||||
if (hasTotalDistance() && previous != null && previous.hasTotalDistance()) {
|
Distance overallDistance = null;
|
||||||
overallDistance = this.totalDistance.minus(previous.totalDistance);
|
if (previous != null && previous.hasTotalDistance()) {
|
||||||
if (previous.hasValue() && previous.getValue().getDistance() != null) {
|
overallDistance = this.totalDistance.minus(previous.totalDistance);
|
||||||
overallDistance = overallDistance.plus(previous.getValue().getDistance());
|
if (previous.hasValue() && previous.getValue().getDistance() != null) {
|
||||||
|
overallDistance = overallDistance.plus(previous.getValue().getDistance());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
value = new Data(speed, cadence, overallDistance);
|
value = new Data(speed, cadence, overallDistance);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user