use of nodomain.freeyourgadget.gadgetbridge.devices.fitpro.FitProSampleProvider in project Gadgetbridge by Freeyourgadget.
the class FitProDeviceSupport method getStepsOnDay.
private int getStepsOnDay(Calendar dayStart, Calendar dayEnd) {
// this is for day data values, not used in Gb, handleStepData uses 5min data which is better
try (DBHandler dbHandler = GBApplication.acquireDB()) {
FitProSampleProvider provider = new FitProSampleProvider(this.getDevice(), dbHandler.getDaoSession());
List<FitProActivitySample> samples = provider.getActivitySamples((int) (dayStart.getTimeInMillis() / 1000L), (int) (dayEnd.getTimeInMillis() / 1000L));
int totalSteps = 0;
for (FitProActivitySample sample : samples) {
totalSteps += sample.getSteps();
}
return totalSteps;
} catch (Exception ex) {
LOG.error(ex.getMessage());
return 0;
}
}
use of nodomain.freeyourgadget.gadgetbridge.devices.fitpro.FitProSampleProvider in project Gadgetbridge by Freeyourgadget.
the class FitProDeviceSupport method addGBActivitySamples.
private boolean addGBActivitySamples(List<FitProActivitySample> samples) {
try (DBHandler dbHandler = GBApplication.acquireDB()) {
User user = DBHelper.getUser(dbHandler.getDaoSession());
Device device = DBHelper.getDevice(this.getDevice(), dbHandler.getDaoSession());
FitProSampleProvider provider = new FitProSampleProvider(this.getDevice(), dbHandler.getDaoSession());
for (FitProActivitySample sample : samples) {
sample.setDevice(device);
sample.setUser(user);
sample.setProvider(provider);
provider.addGBActivitySample(sample);
}
} catch (Exception ex) {
LOG.error("Error saving samples: " + ex);
GB.updateTransferNotification(null, "Data transfer failed", false, 0, getContext());
return false;
}
return true;
}
Aggregations