mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-24 09:35:50 +01:00
Fix the logic regarding the last sample of a run. Remove the unneded try-catch block and reuse the current DB session instead.
This commit is contained in:
parent
5a3a0495c9
commit
b617ba7264
@ -454,13 +454,15 @@ public class DBHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (currentTypeRun != previousTypeRun) {
|
if (currentTypeRun != previousTypeRun) {
|
||||||
|
//we used not to store the last sample, now we do the opposite and we need to round up
|
||||||
|
currentTypeEndTimeStamp = currentTimeStamp;
|
||||||
//if the Type has changed, the run has ended. Only store light and deep sleep data
|
//if the Type has changed, the run has ended. Only store light and deep sleep data
|
||||||
if (previousTypeRun == 4) {
|
if (previousTypeRun == 4) {
|
||||||
overlayList.add(new PebbleHealthActivityOverlay(currentTypeStartTimeStamp, currentTypeEndTimeStamp, sampleProvider.toRawActivityKind(ActivityKind.TYPE_LIGHT_SLEEP), deviceId, userId, null));
|
overlayList.add(new PebbleHealthActivityOverlay(currentTypeStartTimeStamp, currentTypeEndTimeStamp, sampleProvider.toRawActivityKind(ActivityKind.TYPE_LIGHT_SLEEP), deviceId, userId, null));
|
||||||
} else if (previousTypeRun == 5) {
|
} else if (previousTypeRun == 5) {
|
||||||
overlayList.add(new PebbleHealthActivityOverlay(currentTypeStartTimeStamp, currentTypeEndTimeStamp, sampleProvider.toRawActivityKind(ActivityKind.TYPE_DEEP_SLEEP), deviceId, userId, null));
|
overlayList.add(new PebbleHealthActivityOverlay(currentTypeStartTimeStamp, currentTypeEndTimeStamp, sampleProvider.toRawActivityKind(ActivityKind.TYPE_DEEP_SLEEP), deviceId, userId, null));
|
||||||
}
|
}
|
||||||
currentTypeStartTimeStamp = currentTypeEndTimeStamp = currentTimeStamp;
|
currentTypeStartTimeStamp = currentTimeStamp;
|
||||||
previousTypeRun = currentTypeRun;
|
previousTypeRun = currentTypeRun;
|
||||||
} else {
|
} else {
|
||||||
//just expand the run
|
//just expand the run
|
||||||
@ -488,14 +490,8 @@ public class DBHelper {
|
|||||||
}
|
}
|
||||||
// store the overlay records
|
// store the overlay records
|
||||||
if (!overlayList.isEmpty()) {
|
if (!overlayList.isEmpty()) {
|
||||||
try (DBHandler dbHandler = GBApplication.acquireDB()) {
|
PebbleHealthActivityOverlayDao overlayDao = targetSession.getPebbleHealthActivityOverlayDao();
|
||||||
DaoSession session = dbHandler.getDaoSession();
|
overlayDao.insertOrReplaceInTx(overlayList);
|
||||||
PebbleHealthActivityOverlayDao overlayDao = session.getPebbleHealthActivityOverlayDao();
|
|
||||||
overlayDao.insertOrReplaceInTx(overlayList);
|
|
||||||
|
|
||||||
} catch (Exception ex) {
|
|
||||||
//FIXME: this whole try catch is probably in the wrong place.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user