use of nodomain.freeyourgadget.gadgetbridge.devices.pebble.PebbleHealthSampleProvider in project Gadgetbridge by Freeyourgadget.
the class DatalogSessionHealthSteps method store.
private void store(StepsRecord[] stepsRecords) {
try (DBHandler dbHandler = GBApplication.acquireDB()) {
PebbleHealthSampleProvider sampleProvider = new PebbleHealthSampleProvider(getDevice(), dbHandler.getDaoSession());
PebbleHealthActivitySample[] samples = new PebbleHealthActivitySample[stepsRecords.length];
// TODO: user and device
Long userId = DBHelper.getUser(dbHandler.getDaoSession()).getId();
Long deviceId = DBHelper.getDevice(getDevice(), dbHandler.getDaoSession()).getId();
for (int j = 0; j < stepsRecords.length; j++) {
StepsRecord stepsRecord = stepsRecords[j];
samples[j] = new PebbleHealthActivitySample(stepsRecord.timestamp, deviceId, userId, stepsRecord.getRawData(), stepsRecord.intensity, stepsRecord.steps, stepsRecord.heart_rate);
samples[j].setProvider(sampleProvider);
}
sampleProvider.addGBActivitySamples(samples);
} catch (Exception ex) {
LOG.debug(ex.getMessage());
}
}
Aggregations