use of nodomain.freeyourgadget.gadgetbridge.entities.PebbleHealthActivityOverlayDao in project Gadgetbridge by Freeyourgadget.
the class DatalogSessionHealthOverlayData method store.
private void store(OverlayRecord[] overlayRecords) {
try (DBHandler dbHandler = GBApplication.acquireDB()) {
DaoSession session = dbHandler.getDaoSession();
Long userId = DBHelper.getUser(session).getId();
Long deviceId = DBHelper.getDevice(getDevice(), session).getId();
PebbleHealthActivityOverlayDao overlayDao = session.getPebbleHealthActivityOverlayDao();
List<PebbleHealthActivityOverlay> overlayList = new ArrayList<>();
for (OverlayRecord overlayRecord : overlayRecords) {
overlayList.add(new PebbleHealthActivityOverlay(overlayRecord.timestampStart, overlayRecord.timestampStart + overlayRecord.durationSeconds, overlayRecord.type, deviceId, userId, overlayRecord.getRawData()));
}
overlayDao.insertOrReplaceInTx(overlayList);
} catch (Exception ex) {
LOG.debug(ex.getMessage());
}
}
use of nodomain.freeyourgadget.gadgetbridge.entities.PebbleHealthActivityOverlayDao in project Gadgetbridge by Freeyourgadget.
the class DatalogSessionHealthSleep method store.
private void store(SleepRecord[] sleepRecords) {
try (DBHandler dbHandler = GBApplication.acquireDB()) {
DaoSession session = dbHandler.getDaoSession();
Long userId = DBHelper.getUser(session).getId();
Long deviceId = DBHelper.getDevice(getDevice(), session).getId();
PebbleHealthActivityOverlayDao overlayDao = session.getPebbleHealthActivityOverlayDao();
List<PebbleHealthActivityOverlay> overlayList = new ArrayList<>();
for (SleepRecord sleepRecord : sleepRecords) {
//TODO: check the firmware version and don't use the sleep record if overlay is available?
overlayList.add(new PebbleHealthActivityOverlay(sleepRecord.bedTimeStart, sleepRecord.bedTimeEnd, sleepRecord.type, deviceId, userId, sleepRecord.getRawData()));
}
overlayDao.insertOrReplaceInTx(overlayList);
} catch (Exception ex) {
LOG.debug(ex.getMessage());
}
}
Aggregations