forked from upstream-mirrors/OpenTracks
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:
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user