mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-27 02:55:50 +01:00
VO2Max: Display latest sample from period
This commit is contained in:
parent
d440ec1e36
commit
9f0d426a9f
@ -289,7 +289,7 @@ public class VO2MaxFragment extends AbstractChartFragment<VO2MaxFragment.VO2MaxD
|
|||||||
public Vo2MaxSample getLatestVo2MaxSample(final DBHandler db, final GBDevice device, Vo2MaxSample.Type type) {
|
public Vo2MaxSample getLatestVo2MaxSample(final DBHandler db, final GBDevice device, Vo2MaxSample.Type type) {
|
||||||
final DeviceCoordinator coordinator = device.getDeviceCoordinator();
|
final DeviceCoordinator coordinator = device.getDeviceCoordinator();
|
||||||
final Vo2MaxSampleProvider sampleProvider = (Vo2MaxSampleProvider) coordinator.getVo2MaxSampleProvider(device, db.getDaoSession());
|
final Vo2MaxSampleProvider sampleProvider = (Vo2MaxSampleProvider) coordinator.getVo2MaxSampleProvider(device, db.getDaoSession());
|
||||||
return sampleProvider.getLatestSample(type);
|
return sampleProvider.getLatestSample(type, getTSEnd() * 1000L);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupVO2MaxChart() {
|
private void setupVO2MaxChart() {
|
||||||
|
@ -6,5 +6,5 @@ import nodomain.freeyourgadget.gadgetbridge.model.Vo2MaxSample;
|
|||||||
|
|
||||||
public interface Vo2MaxSampleProvider<T extends Vo2MaxSample> extends TimeSampleProvider<T> {
|
public interface Vo2MaxSampleProvider<T extends Vo2MaxSample> extends TimeSampleProvider<T> {
|
||||||
@Nullable
|
@Nullable
|
||||||
T getLatestSample(Vo2MaxSample.Type type);
|
T getLatestSample(Vo2MaxSample.Type type, long until);
|
||||||
}
|
}
|
||||||
|
@ -96,7 +96,7 @@ public class GarminVo2MaxSampleProvider implements Vo2MaxSampleProvider<Vo2MaxSa
|
|||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public Vo2MaxSample getLatestSample(final Vo2MaxSample.Type type) {
|
public Vo2MaxSample getLatestSample(final Vo2MaxSample.Type type, final long until) {
|
||||||
final BaseActivitySummaryDao summaryDao = session.getBaseActivitySummaryDao();
|
final BaseActivitySummaryDao summaryDao = session.getBaseActivitySummaryDao();
|
||||||
final Device dbDevice = DBHelper.findDevice(device, session);
|
final Device dbDevice = DBHelper.findDevice(device, session);
|
||||||
if (dbDevice == null) {
|
if (dbDevice == null) {
|
||||||
@ -129,6 +129,10 @@ public class GarminVo2MaxSampleProvider implements Vo2MaxSampleProvider<Vo2MaxSa
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (until != 0) {
|
||||||
|
qb.where(BaseActivitySummaryDao.Properties.EndTime.le(new Date(until)));
|
||||||
|
}
|
||||||
|
|
||||||
qb.where(BaseActivitySummaryDao.Properties.DeviceId.eq(dbDevice.getId()))
|
qb.where(BaseActivitySummaryDao.Properties.DeviceId.eq(dbDevice.getId()))
|
||||||
.orderDesc(BaseActivitySummaryDao.Properties.StartTime)
|
.orderDesc(BaseActivitySummaryDao.Properties.StartTime)
|
||||||
.limit(1);
|
.limit(1);
|
||||||
@ -142,7 +146,7 @@ public class GarminVo2MaxSampleProvider implements Vo2MaxSampleProvider<Vo2MaxSa
|
|||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public Vo2MaxSample getLatestSample() {
|
public Vo2MaxSample getLatestSample() {
|
||||||
return getLatestSample(Vo2MaxSample.Type.GENERAL);
|
return getLatestSample(Vo2MaxSample.Type.GENERAL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
Loading…
Reference in New Issue
Block a user