Search in sources :

Example 1 with PebbleHealthSampleProvider

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());
    }
}
Also used : DBHandler(nodomain.freeyourgadget.gadgetbridge.database.DBHandler) PebbleHealthSampleProvider(nodomain.freeyourgadget.gadgetbridge.devices.pebble.PebbleHealthSampleProvider) PebbleHealthActivitySample(nodomain.freeyourgadget.gadgetbridge.entities.PebbleHealthActivitySample)

Aggregations

DBHandler (nodomain.freeyourgadget.gadgetbridge.database.DBHandler)1 PebbleHealthSampleProvider (nodomain.freeyourgadget.gadgetbridge.devices.pebble.PebbleHealthSampleProvider)1 PebbleHealthActivitySample (nodomain.freeyourgadget.gadgetbridge.entities.PebbleHealthActivitySample)1