forked from upstream-mirrors/OpenTracks
Cleanup: Move current time handling into SensorManager.
This commit is contained in:
@@ -250,13 +250,16 @@ public class SensorManager implements SharedPreferences.OnSharedPreferenceChange
|
|||||||
}
|
}
|
||||||
|
|
||||||
public SensorDataSet getSensorDataSet(Instant now) {
|
public SensorDataSet getSensorDataSet(Instant now) {
|
||||||
|
//We always need a Position with now
|
||||||
SensorData<Position> gpsSensorData = gpsHandler.getSensorData(now);
|
SensorData<Position> gpsSensorData = gpsHandler.getSensorData(now);
|
||||||
|
if (gpsSensorData != null && gpsSensorData.data() != null) {
|
||||||
var a = temperatureHandler.getSensorData(now);
|
gpsSensorData = new SensorData<>(gpsSensorData.data().with(now), gpsSensorData.sensorNameOrAddress());
|
||||||
var b = altitudeChangeHandler.getSensorData(now);
|
} else {
|
||||||
|
gpsSensorData = new SensorData<>(Position.of(now), "");
|
||||||
|
}
|
||||||
|
|
||||||
return new SensorDataSet(
|
return new SensorDataSet(
|
||||||
gpsSensorData != null ? gpsSensorData : new SensorData<>(Position.of(now), ""), //We always need a Position(now)
|
gpsSensorData,
|
||||||
getSpeed(now),
|
getSpeed(now),
|
||||||
getDistance(now),
|
getDistance(now),
|
||||||
getHeartRate(now),
|
getHeartRate(now),
|
||||||
|
|||||||
@@ -2,10 +2,6 @@ package de.dennisguse.opentracks.sensors.sensorData;
|
|||||||
|
|
||||||
import android.location.Location;
|
import android.location.Location;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
|
|
||||||
import java.time.Instant;
|
|
||||||
|
|
||||||
import de.dennisguse.opentracks.data.models.Position;
|
import de.dennisguse.opentracks.data.models.Position;
|
||||||
|
|
||||||
public class AggregatorGPS extends Aggregator<Location, Position> {
|
public class AggregatorGPS extends Aggregator<Location, Position> {
|
||||||
@@ -28,13 +24,4 @@ public class AggregatorGPS extends Aggregator<Location, Position> {
|
|||||||
*/
|
*/
|
||||||
output = null;
|
output = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public Position getAggregatedValue(Instant now) {
|
|
||||||
Position value = super.getAggregatedValue(now);
|
|
||||||
if (value == null) value = Position.empty();
|
|
||||||
|
|
||||||
return value.with(now);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user