TrackStatistics and ChartView: handle altitude and speed as optional with null as default value.

Then only the relevant part of the y-axis is shown.

Fixes #795.
This commit is contained in:
Dennis Guse
2021-12-29 23:12:49 +01:00
parent 8c20d5583a
commit 07074ad260
11 changed files with 172 additions and 73 deletions
@@ -0,0 +1,32 @@
package de.dennisguse.opentracks.stats;
import androidx.annotation.Nullable;
import de.dennisguse.opentracks.content.data.Altitude;
public class AltitudeRingBuffer extends RingBuffer<Altitude> {
private Altitude firstAltitude;
AltitudeRingBuffer(int size) {
super(size);
}
AltitudeRingBuffer(RingBuffer<Altitude> toCopy) {
super(toCopy);
}
@Nullable
@Override
protected Number from(Altitude object) {
if (firstAltitude == null) {
firstAltitude = object;
}
return object.toM();
}
@Override
protected Altitude to(double object) {
return firstAltitude.replace(object);
}
}