Only invoke the loop for new BGs.
This commit is contained in:
parent
1e359184a9
commit
063505fdb3
3 changed files with 10 additions and 8 deletions
|
@ -241,7 +241,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
|||
log.error("Unhandled exception", e);
|
||||
}
|
||||
VirtualPumpPlugin.setFakingStatus(true);
|
||||
scheduleBgChange(null); // trigger refresh
|
||||
scheduleBgChange(null, false); // trigger refresh
|
||||
scheduleTemporaryBasalChange();
|
||||
scheduleTreatmentChange(null);
|
||||
scheduleExtendedBolusChange();
|
||||
|
@ -374,7 +374,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
|||
if (old == null) {
|
||||
getDaoBgReadings().create(bgReading);
|
||||
log.debug("BG: New record from: " + from + " " + bgReading.toString());
|
||||
scheduleBgChange(bgReading);
|
||||
scheduleBgChange(bgReading, true);
|
||||
return true;
|
||||
}
|
||||
if (!old.isEqual(bgReading)) {
|
||||
|
@ -382,7 +382,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
|||
old.copyFrom(bgReading);
|
||||
getDaoBgReadings().update(old);
|
||||
log.debug("BG: Updating record from: " + from + " New data: " + old.toString());
|
||||
scheduleBgChange(bgReading);
|
||||
scheduleBgChange(bgReading, false);
|
||||
return false;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
|
@ -400,11 +400,11 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
|||
}
|
||||
}
|
||||
|
||||
private static void scheduleBgChange(@Nullable final BgReading bgReading) {
|
||||
private static void scheduleBgChange(@Nullable final BgReading bgReading, boolean isNew) {
|
||||
class PostRunnable implements Runnable {
|
||||
public void run() {
|
||||
log.debug("Firing EventNewBg");
|
||||
MainApp.bus().post(new EventNewBG(bgReading));
|
||||
MainApp.bus().post(new EventNewBG(bgReading, isNew));
|
||||
scheduledBgPost = null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,8 +10,10 @@ import info.nightscout.androidaps.db.BgReading;
|
|||
public class EventNewBG extends EventLoop {
|
||||
@Nullable
|
||||
public final BgReading bgReading;
|
||||
public final boolean isNew;
|
||||
|
||||
public EventNewBG(BgReading bgReading) {
|
||||
public EventNewBG(BgReading bgReading, boolean isNew) {
|
||||
this.bgReading = bgReading;
|
||||
this.isNew = isNew;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -159,8 +159,8 @@ public class LoopPlugin implements PluginBase {
|
|||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventAutosensCalculationFinished ev) {
|
||||
if (ev.cause instanceof EventNewBG) {
|
||||
invoke(ev.getClass().getSimpleName() + "(" + ev.cause.getClass().getSimpleName() + ")", true);
|
||||
if (ev.cause instanceof EventNewBG && ((EventNewBG) ev.cause).isNew) {
|
||||
invoke("New BG", true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue