mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-24 17:45:50 +01:00
Set sampleProvider to avoid NPEs
This commit is contained in:
parent
9eb768ace0
commit
8b24e098ea
@ -335,7 +335,7 @@ public class FetchActivityOperation extends AbstractMiBandOperation {
|
||||
userId,
|
||||
deviceId,
|
||||
heartrate & 0xff);
|
||||
// samples[minutes].setProvider(dbHandler);
|
||||
samples[minutes].setProvider(provider);
|
||||
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("sample: " + samples[minutes]);
|
||||
|
@ -67,6 +67,7 @@ public class AppMessageHandlerGBPebble extends AppMessageHandler {
|
||||
int intensity = ((sample & 0x1f80) >>> 7);
|
||||
int steps = (sample & 0x007f);
|
||||
activitySamples[i++] = createSample(timestamp + offset_seconds, intensity, steps, type, user, device);
|
||||
activitySamples[i].setProvider(sampleProvider);
|
||||
offset_seconds += 60;
|
||||
}
|
||||
sampleProvider.addGBActivitySamples(activitySamples);
|
||||
|
@ -82,6 +82,7 @@ public class AppMessageHandlerMisfit extends AppMessageHandler {
|
||||
int totalSteps = 0;
|
||||
PebbleActivitySample[] activitySamples = new PebbleActivitySample[samples];
|
||||
try (DBHandler db = GBApplication.acquireDB()) {
|
||||
MisfitSampleProvider sampleProvider = new MisfitSampleProvider(device, db.getDaoSession());
|
||||
Long userId = DBHelper.getUser(db.getDaoSession()).getId();
|
||||
Long deviceId = DBHelper.getDevice(getDevice(), db.getDaoSession()).getId();
|
||||
for (int i = 0; i < samples; i++) {
|
||||
@ -115,10 +116,10 @@ public class AppMessageHandlerMisfit extends AppMessageHandler {
|
||||
LOG.info("got steps for sample " + i + " : " + steps + "(" + Integer.toHexString(sample & 0xffff) + ")");
|
||||
|
||||
activitySamples[i] = new PebbleActivitySample(null, timestamp + i * 60, intensity, steps, activityKind, userId, deviceId);
|
||||
activitySamples[i].setProvider(sampleProvider);
|
||||
}
|
||||
LOG.info("total steps for above period: " + totalSteps);
|
||||
|
||||
MisfitSampleProvider sampleProvider = new MisfitSampleProvider(device, db.getDaoSession());
|
||||
sampleProvider.addGBActivitySamples(activitySamples);
|
||||
} catch (Exception e) {
|
||||
LOG.error("Error acquiring database", e);
|
||||
|
@ -19,6 +19,7 @@ import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventSleepMonit
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.SampleProvider;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.pebble.MorpheuzSampleProvider;
|
||||
import nodomain.freeyourgadget.gadgetbridge.entities.Device;
|
||||
import nodomain.freeyourgadget.gadgetbridge.entities.PebbleActivitySample;
|
||||
import nodomain.freeyourgadget.gadgetbridge.entities.User;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
|
||||
|
||||
@ -103,7 +104,9 @@ public class AppMessageHandlerMorpheuz extends AppMessageHandler {
|
||||
User user = DBHelper.getUser(db.getDaoSession());
|
||||
Device device = DBHelper.getDevice(getDevice(), db.getDaoSession());
|
||||
MorpheuzSampleProvider sampleProvider = new MorpheuzSampleProvider(getDevice(), db.getDaoSession());
|
||||
sampleProvider.addGBActivitySample(createSample(recording_base_timestamp + index * 600, intensity, 0, type, user, device));
|
||||
PebbleActivitySample sample = createSample(recording_base_timestamp + index * 600, intensity, 0, type, user, device);
|
||||
sample.setProvider(sampleProvider);
|
||||
sampleProvider.addGBActivitySample(sample);
|
||||
} catch (Exception e) {
|
||||
LOG.error("Error acquiring database", e);
|
||||
}
|
||||
|
@ -89,6 +89,7 @@ public class DatalogSessionHealthSteps extends DatalogSessionPebbleHealth {
|
||||
stepsRecord.steps,
|
||||
sampleProvider.toRawActivityKind(ActivityKind.TYPE_ACTIVITY),
|
||||
userId, deviceId);
|
||||
samples[j].setProvider(sampleProvider);
|
||||
}
|
||||
|
||||
sampleProvider.addGBActivitySamples(samples);
|
||||
|
Loading…
Reference in New Issue
Block a user