fixing bugs after refactoring

This commit is contained in:
Milos Kozak 2016-08-07 23:21:08 +02:00
parent 12b014afd4
commit 294f9d6c99
13 changed files with 150 additions and 164 deletions

View file

@ -107,10 +107,10 @@ public class DataService extends IntentService {
} else if (Telephony.Sms.Intents.SMS_RECEIVED_ACTION.equals(action)) { } else if (Telephony.Sms.Intents.SMS_RECEIVED_ACTION.equals(action)) {
handleNewSMS(intent); handleNewSMS(intent);
} }
DataReceiver.completeWakefulIntent(intent);
} }
if (Config.logFunctionCalls) if (Config.logFunctionCalls)
log.debug("onHandleIntent exit"); log.debug("onHandleIntent exit " + intent);
DataReceiver.completeWakefulIntent(intent);
} }
/* /*

View file

@ -28,9 +28,6 @@ import java.util.List;
import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.events.EventNewBG;
import info.nightscout.androidaps.events.EventTempBasalChange;
import info.nightscout.androidaps.events.EventTreatmentChange;
import info.nightscout.utils.DecimalFormatter; import info.nightscout.utils.DecimalFormatter;
import info.nightscout.utils.Round; import info.nightscout.utils.Round;
@ -218,13 +215,13 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
@Override @Override
public String toString() { public String toString() {
return MainApp.sResources.getString(R.string.glucose) + " " + DecimalFormatter.to0Decimal(glucose) + " mg/dl\n" + return MainApp.sResources.getString(R.string.glucose) + " " + DecimalFormatter.to0Decimal(glucose) + " mg/dl\n" +
MainApp.sResources.getString(R.string.delta) + " " + DecimalFormatter.to0Decimal(delta) + " mg/dl\n" + MainApp.sResources.getString(R.string.delta) + " " + DecimalFormatter.to0Decimal(delta) + " mg/dl\n" +
MainApp.sResources.getString(R.string.avgdelta) + " " + DecimalFormatter.to2Decimal(avgdelta) + " mg/dl"; MainApp.sResources.getString(R.string.avgdelta) + " " + DecimalFormatter.to2Decimal(avgdelta) + " mg/dl";
} }
public Spanned toSpanned() { public Spanned toSpanned() {
return Html.fromHtml("<b>" + MainApp.sResources.getString(R.string.glucose) + "</b>: " + DecimalFormatter.to0Decimal(glucose) + " mg/dl<br>" + return Html.fromHtml("<b>" + MainApp.sResources.getString(R.string.glucose) + "</b>: " + DecimalFormatter.to0Decimal(glucose) + " mg/dl<br>" +
"<b>" + MainApp.sResources.getString(R.string.delta) + "</b>: " + DecimalFormatter.to0Decimal(delta) + " mg/dl<br>" + "<b>" + MainApp.sResources.getString(R.string.delta) + "</b>: " + DecimalFormatter.to0Decimal(delta) + " mg/dl<br>" +
"<b>" + MainApp.sResources.getString(R.string.avgdelta) + "</b>: " + DecimalFormatter.to2Decimal(avgdelta) + " mg/dl"); "<b>" + MainApp.sResources.getString(R.string.avgdelta) + "</b>: " + DecimalFormatter.to2Decimal(avgdelta) + " mg/dl");
} }
@ -240,6 +237,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
dest.writeDouble(delta); dest.writeDouble(delta);
dest.writeDouble(glucose); dest.writeDouble(glucose);
} }
public final Parcelable.Creator<GlucoseStatus> CREATOR = new Parcelable.Creator<GlucoseStatus>() { public final Parcelable.Creator<GlucoseStatus> CREATOR = new Parcelable.Creator<GlucoseStatus>() {
public GlucoseStatus createFromParcel(Parcel in) { public GlucoseStatus createFromParcel(Parcel in) {
return new GlucoseStatus(in); return new GlucoseStatus(in);
@ -256,7 +254,8 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
glucose = in.readDouble(); glucose = in.readDouble();
} }
public GlucoseStatus() {} public GlucoseStatus() {
}
public GlucoseStatus(Double glucose, Double delta, Double avgdelta) { public GlucoseStatus(Double glucose, Double delta, Double avgdelta) {
this.glucose = glucose; this.glucose = glucose;

View file

@ -1,7 +0,0 @@
package info.nightscout.androidaps.events;
/**
* Created by mike on 25.06.2016.
*/
public class EventRefreshOpenLoop {
}

View file

@ -655,16 +655,22 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
@Subscribe @Subscribe
public void onStatusEvent(final EventNewBG ev) { public void onStatusEvent(final EventNewBG ev) {
// Give some time to Loop Thread t = new Thread(new Runnable() {
try { @Override
Thread.sleep(120 * 1000L); public void run() {
} catch (InterruptedException e) { // Give some time to Loop
e.printStackTrace(); try {
} Thread.sleep(120 * 1000L);
// if status not uploaded, upload pump status only } catch (InterruptedException e) {
if (new Date().getTime() - lastDeviceStatusUpload.getTime() > 120 * 1000L) { e.printStackTrace();
uploadDeviceStatus(); }
} // if status not uploaded, upload pump status only
if (new Date().getTime() - lastDeviceStatusUpload.getTime() > 120 * 1000L) {
uploadDeviceStatus();
}
}
});
t.start();
} }
public void uploadTempBasalStartAbsolute(Double absolute, double durationInMinutes) { public void uploadTempBasalStartAbsolute(Double absolute, double durationInMinutes) {

View file

@ -12,16 +12,18 @@ import android.support.v7.app.NotificationCompat;
import com.squareup.otto.Subscribe; import com.squareup.otto.Subscribe;
import java.util.ArrayList; import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Date; import java.util.Date;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainActivity; import info.nightscout.androidaps.MainActivity;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.PumpEnactResult; import info.nightscout.androidaps.data.PumpEnactResult;
import info.nightscout.androidaps.events.EventNewBG; import info.nightscout.androidaps.events.EventNewBG;
import info.nightscout.androidaps.events.EventRefreshOpenLoop;
import info.nightscout.androidaps.events.EventTreatmentChange; import info.nightscout.androidaps.events.EventTreatmentChange;
import info.nightscout.androidaps.interfaces.APSInterface; import info.nightscout.androidaps.interfaces.APSInterface;
import info.nightscout.androidaps.interfaces.ConstraintsInterface; import info.nightscout.androidaps.interfaces.ConstraintsInterface;
@ -29,11 +31,14 @@ import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.Loop.events.EventLoopSetLastRunGui; import info.nightscout.androidaps.plugins.Loop.events.EventLoopSetLastRunGui;
import info.nightscout.androidaps.plugins.Loop.events.EventLoopUpdateGui; import info.nightscout.androidaps.plugins.Loop.events.EventLoopUpdateGui;
import info.nightscout.androidaps.plugins.Loop.events.EventNewOpenLoopNotification;
/** /**
* Created by mike on 05.08.2016. * Created by mike on 05.08.2016.
*/ */
public class LoopPlugin implements PluginBase { public class LoopPlugin implements PluginBase {
private static Logger log = LoggerFactory.getLogger(LoopPlugin.class);
private static Handler sHandler; private static Handler sHandler;
private static HandlerThread sHandlerThread; private static HandlerThread sHandlerThread;
@ -112,101 +117,108 @@ public class LoopPlugin implements PluginBase {
} }
public void invoke(boolean allowNotification) { public void invoke(boolean allowNotification) {
ConstraintsInterface constraintsInterface = MainApp.getConfigBuilder(); try {
if (!constraintsInterface.isLoopEnabled()) { if (Config.logFunctionCalls)
MainApp.bus().post(new EventLoopSetLastRunGui(MainApp.sResources.getString(R.string.loopdisabled))); log.debug("invoke");
return; ConstraintsInterface constraintsInterface = MainApp.getConfigBuilder();
} if (!constraintsInterface.isLoopEnabled()) {
final ConfigBuilderPlugin configBuilder = MainApp.getConfigBuilder(); MainApp.bus().post(new EventLoopSetLastRunGui(MainApp.sResources.getString(R.string.loopdisabled)));
APSResult result = null; return;
}
final ConfigBuilderPlugin configBuilder = MainApp.getConfigBuilder();
APSResult result = null;
if (configBuilder == null || !isEnabled(PluginBase.GENERAL)) if (configBuilder == null || !isEnabled(PluginBase.GENERAL))
return; return;
APSInterface usedAPS = configBuilder.getActiveAPS(); APSInterface usedAPS = configBuilder.getActiveAPS();
if (usedAPS != null && ((PluginBase) usedAPS).isEnabled(PluginBase.APS)) { if (usedAPS != null && ((PluginBase) usedAPS).isEnabled(PluginBase.APS)) {
usedAPS.invoke(); usedAPS.invoke();
result = usedAPS.getLastAPSResult(); result = usedAPS.getLastAPSResult();
} }
// Check if we have any result // Check if we have any result
if (result == null) { if (result == null) {
MainApp.bus().post(new EventLoopSetLastRunGui(MainApp.sResources.getString(R.string.noapsselected))); MainApp.bus().post(new EventLoopSetLastRunGui(MainApp.sResources.getString(R.string.noapsselected)));
return; return;
} }
// check rate for constrais // check rate for constrais
final APSResult resultAfterConstraints = result.clone(); final APSResult resultAfterConstraints = result.clone();
resultAfterConstraints.rate = constraintsInterface.applyBasalConstraints(resultAfterConstraints.rate); resultAfterConstraints.rate = constraintsInterface.applyBasalConstraints(resultAfterConstraints.rate);
if (lastRun == null) lastRun = new LastRun(); if (lastRun == null) lastRun = new LastRun();
lastRun.request = result; lastRun.request = result;
lastRun.constraintsProcessed = resultAfterConstraints; lastRun.constraintsProcessed = resultAfterConstraints;
lastRun.lastAPSRun = new Date(); lastRun.lastAPSRun = new Date();
lastRun.source = ((PluginBase) usedAPS).getName(); lastRun.source = ((PluginBase) usedAPS).getName();
lastRun.setByPump = null; lastRun.setByPump = null;
if (constraintsInterface.isClosedModeEnabled()) { if (constraintsInterface.isClosedModeEnabled()) {
if (result.changeRequested) { if (result.changeRequested) {
final PumpEnactResult waiting = new PumpEnactResult(); final PumpEnactResult waiting = new PumpEnactResult();
final PumpEnactResult previousResult = lastRun.setByPump; final PumpEnactResult previousResult = lastRun.setByPump;
waiting.queued = true; waiting.queued = true;
lastRun.setByPump = waiting; lastRun.setByPump = waiting;
MainApp.bus().post(new EventLoopUpdateGui()); MainApp.bus().post(new EventLoopUpdateGui());
sHandler.post(new Runnable() { sHandler.post(new Runnable() {
@Override @Override
public void run() { public void run() {
final PumpEnactResult applyResult = configBuilder.applyAPSRequest(resultAfterConstraints); final PumpEnactResult applyResult = configBuilder.applyAPSRequest(resultAfterConstraints);
if (applyResult.enacted) { if (applyResult.enacted) {
lastRun.setByPump = applyResult; lastRun.setByPump = applyResult;
lastRun.lastEnact = lastRun.lastAPSRun; lastRun.lastEnact = lastRun.lastAPSRun;
} else { } else {
lastRun.setByPump = previousResult; lastRun.setByPump = previousResult;
}
MainApp.bus().post(new EventLoopUpdateGui());
} }
MainApp.bus().post(new EventLoopUpdateGui()); });
} } else {
}); lastRun.setByPump = null;
lastRun.source = null;
}
} else { } else {
lastRun.setByPump = null; if (result.changeRequested && allowNotification) {
lastRun.source = null; NotificationCompat.Builder builder =
} new NotificationCompat.Builder(MainApp.instance().getApplicationContext());
} else { builder.setSmallIcon(R.drawable.notification_icon)
if (result.changeRequested && allowNotification) { .setContentTitle(MainApp.sResources.getString(R.string.openloop_newsuggestion))
NotificationCompat.Builder builder = .setContentText(resultAfterConstraints.toString())
new NotificationCompat.Builder(MainApp.instance().getApplicationContext()); .setAutoCancel(true)
builder.setSmallIcon(R.drawable.notification_icon) .setPriority(Notification.PRIORITY_HIGH)
.setContentTitle(MainApp.sResources.getString(R.string.openloop_newsuggestion)) .setCategory(Notification.CATEGORY_ALARM)
.setContentText(resultAfterConstraints.toString()) .setVisibility(Notification.VISIBILITY_PUBLIC);
.setAutoCancel(true)
.setPriority(Notification.PRIORITY_HIGH)
.setCategory(Notification.CATEGORY_ALARM)
.setVisibility(Notification.VISIBILITY_PUBLIC);
// Creates an explicit intent for an Activity in your app // Creates an explicit intent for an Activity in your app
Intent resultIntent = new Intent(MainApp.instance().getApplicationContext(), MainActivity.class); Intent resultIntent = new Intent(MainApp.instance().getApplicationContext(), MainActivity.class);
// The stack builder object will contain an artificial back stack for the // The stack builder object will contain an artificial back stack for the
// started Activity. // started Activity.
// This ensures that navigating backward from the Activity leads out of // This ensures that navigating backward from the Activity leads out of
// your application to the Home screen. // your application to the Home screen.
TaskStackBuilder stackBuilder = TaskStackBuilder.create(MainApp.instance().getApplicationContext()); TaskStackBuilder stackBuilder = TaskStackBuilder.create(MainApp.instance().getApplicationContext());
stackBuilder.addParentStack(MainActivity.class); stackBuilder.addParentStack(MainActivity.class);
// Adds the Intent that starts the Activity to the top of the stack // Adds the Intent that starts the Activity to the top of the stack
stackBuilder.addNextIntent(resultIntent); stackBuilder.addNextIntent(resultIntent);
PendingIntent resultPendingIntent = PendingIntent resultPendingIntent =
stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
builder.setContentIntent(resultPendingIntent); builder.setContentIntent(resultPendingIntent);
builder.setVibrate(new long[]{1000, 1000, 1000, 1000, 1000}); builder.setVibrate(new long[]{1000, 1000, 1000, 1000, 1000});
NotificationManager mNotificationManager = NotificationManager mNotificationManager =
(NotificationManager) MainApp.instance().getSystemService(Context.NOTIFICATION_SERVICE); (NotificationManager) MainApp.instance().getSystemService(Context.NOTIFICATION_SERVICE);
// mId allows you to update the notification later on. // mId allows you to update the notification later on.
mNotificationManager.notify(Constants.notificationID, builder.build()); mNotificationManager.notify(Constants.notificationID, builder.build());
MainApp.bus().post(new EventRefreshOpenLoop()); MainApp.bus().post(new EventNewOpenLoopNotification());
}
} }
MainApp.bus().post(new EventLoopUpdateGui());
MainApp.getConfigBuilder().uploadDeviceStatus();
} finally {
if (Config.logFunctionCalls)
log.debug("invoke end");
} }
MainApp.bus().post(new EventLoopUpdateGui());
MainApp.getConfigBuilder().uploadDeviceStatus();
} }
} }

View file

@ -0,0 +1,7 @@
package info.nightscout.androidaps.plugins.Loop.events;
/**
* Created by mike on 07.08.2016.
*/
public class EventNewOpenLoopNotification {
}

View file

@ -48,11 +48,11 @@ import info.nightscout.androidaps.db.Treatment;
import info.nightscout.androidaps.events.EventNewBG; import info.nightscout.androidaps.events.EventNewBG;
import info.nightscout.androidaps.events.EventPreferenceChange; import info.nightscout.androidaps.events.EventPreferenceChange;
import info.nightscout.androidaps.events.EventRefreshGui; import info.nightscout.androidaps.events.EventRefreshGui;
import info.nightscout.androidaps.events.EventRefreshOpenLoop;
import info.nightscout.androidaps.events.EventTempBasalChange; import info.nightscout.androidaps.events.EventTempBasalChange;
import info.nightscout.androidaps.events.EventTreatmentChange; import info.nightscout.androidaps.events.EventTreatmentChange;
import info.nightscout.androidaps.interfaces.PumpInterface; import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.plugins.Loop.LoopPlugin; import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
import info.nightscout.androidaps.plugins.Loop.events.EventNewOpenLoopNotification;
import info.nightscout.androidaps.plugins.Objectives.ObjectivesPlugin; import info.nightscout.androidaps.plugins.Objectives.ObjectivesPlugin;
import info.nightscout.androidaps.plugins.OpenAPSMA.IobTotal; import info.nightscout.androidaps.plugins.OpenAPSMA.IobTotal;
import info.nightscout.androidaps.plugins.Overview.Dialogs.NewExtendedBolusDialog; import info.nightscout.androidaps.plugins.Overview.Dialogs.NewExtendedBolusDialog;
@ -92,8 +92,8 @@ public class OverviewFragment extends Fragment {
Button setExtenedButton; Button setExtenedButton;
Button acceptTempButton; Button acceptTempButton;
private static Handler sLoopHandler = new Handler(); Handler sLoopHandler = new Handler();
private static Runnable sRefreshLoop = null; Runnable sRefreshLoop = null;
private static Handler sHandler; private static Handler sHandler;
private static HandlerThread sHandlerThread; private static HandlerThread sHandlerThread;
@ -114,21 +114,6 @@ public class OverviewFragment extends Fragment {
return new OverviewFragment(); return new OverviewFragment();
} }
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (sRefreshLoop == null) {
sRefreshLoop = new Runnable() {
@Override
public void run() {
updateGUIIfVisible();
sLoopHandler.postDelayed(sRefreshLoop, 60 * 1000L);
}
};
sLoopHandler.postDelayed(sRefreshLoop, 60 * 1000L);
}
}
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) { Bundle savedInstanceState) {
@ -217,6 +202,7 @@ public class OverviewFragment extends Fragment {
sHandler.post(new Runnable() { sHandler.post(new Runnable() {
@Override @Override
public void run() { public void run() {
acceptTempLayout.setVisibility(View.GONE);
PumpEnactResult applyResult = MainApp.getConfigBuilder().applyAPSRequest(finalLastRun.constraintsProcessed); PumpEnactResult applyResult = MainApp.getConfigBuilder().applyAPSRequest(finalLastRun.constraintsProcessed);
if (applyResult.enacted) { if (applyResult.enacted) {
finalLastRun.setByPump = applyResult; finalLastRun.setByPump = applyResult;
@ -249,12 +235,21 @@ public class OverviewFragment extends Fragment {
public void onPause() { public void onPause() {
super.onPause(); super.onPause();
MainApp.bus().unregister(this); MainApp.bus().unregister(this);
sLoopHandler.removeCallbacksAndMessages(null);
} }
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
MainApp.bus().register(this); MainApp.bus().register(this);
sRefreshLoop = new Runnable() {
@Override
public void run() {
updateGUIIfVisible();
sLoopHandler.postDelayed(sRefreshLoop, 60 * 1000L);
}
};
sLoopHandler.postDelayed(sRefreshLoop, 60 * 1000L);
} }
@Subscribe @Subscribe
@ -283,7 +278,7 @@ public class OverviewFragment extends Fragment {
} }
@Subscribe @Subscribe
public void onStatusEvent(final EventRefreshOpenLoop ev) { public void onStatusEvent(final EventNewOpenLoopNotification ev) {
updateGUIIfVisible(); updateGUIIfVisible();
} }

View file

@ -24,9 +24,9 @@ import java.util.List;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.db.TempBasal; import info.nightscout.androidaps.db.TempBasal;
import info.nightscout.androidaps.events.EventTempBasalChange;
import info.nightscout.androidaps.interfaces.FragmentBase; import info.nightscout.androidaps.interfaces.FragmentBase;
import info.nightscout.androidaps.plugins.OpenAPSMA.IobTotal; import info.nightscout.androidaps.plugins.OpenAPSMA.IobTotal;
import info.nightscout.androidaps.plugins.TempBasals.events.EventTempBasalsUpdateGui;
import info.nightscout.utils.DecimalFormatter; import info.nightscout.utils.DecimalFormatter;
@ -163,9 +163,8 @@ public class TempBasalsFragment extends Fragment implements FragmentBase {
MainApp.bus().register(this); MainApp.bus().register(this);
} }
@Subscribe @Subscribe
public void onStatusEvent(final EventTempBasalsUpdateGui s) { public void onStatusEvent(final EventTempBasalChange ev) {
updateGUI(); updateGUI();
} }

View file

@ -29,7 +29,6 @@ import info.nightscout.androidaps.events.EventTempBasalChange;
import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.TempBasalsInterface; import info.nightscout.androidaps.interfaces.TempBasalsInterface;
import info.nightscout.androidaps.plugins.OpenAPSMA.IobTotal; import info.nightscout.androidaps.plugins.OpenAPSMA.IobTotal;
import info.nightscout.androidaps.plugins.TempBasals.events.EventTempBasalsUpdateGui;
/** /**
* Created by mike on 05.08.2016. * Created by mike on 05.08.2016.

View file

@ -1,7 +0,0 @@
package info.nightscout.androidaps.plugins.TempBasals.events;
/**
* Created by mike on 05.08.2016.
*/
public class EventTempBasalsUpdateGui {
}

View file

@ -16,17 +16,12 @@ import android.widget.Button;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import com.j256.ormlite.dao.Dao;
import com.j256.ormlite.stmt.PreparedQuery;
import com.j256.ormlite.stmt.QueryBuilder;
import com.squareup.otto.Subscribe; import com.squareup.otto.Subscribe;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.sql.SQLException;
import java.text.DateFormat; import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -37,12 +32,6 @@ import info.nightscout.androidaps.data.Iob;
import info.nightscout.androidaps.db.Treatment; import info.nightscout.androidaps.db.Treatment;
import info.nightscout.androidaps.events.EventTreatmentChange; import info.nightscout.androidaps.events.EventTreatmentChange;
import info.nightscout.androidaps.interfaces.FragmentBase; import info.nightscout.androidaps.interfaces.FragmentBase;
import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRConnectionStatus;
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRNewStatus;
import info.nightscout.androidaps.plugins.OpenAPSMA.IobTotal;
import info.nightscout.androidaps.plugins.Treatments.events.EventTreatmentsUpdateGui;
import info.nightscout.client.data.NSProfile; import info.nightscout.client.data.NSProfile;
import info.nightscout.utils.DecimalFormatter; import info.nightscout.utils.DecimalFormatter;
@ -185,10 +174,6 @@ public class TreatmentsFragment extends Fragment implements View.OnClickListener
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
MainApp.bus().register(this); MainApp.bus().register(this);
}
@Subscribe
public void onStatusEvent(final EventTreatmentsUpdateGui ev) {
updateGUI(); updateGUI();
} }

View file

@ -3,6 +3,7 @@ package info.nightscout.androidaps.plugins.Treatments;
import com.j256.ormlite.dao.Dao; import com.j256.ormlite.dao.Dao;
import com.j256.ormlite.stmt.PreparedQuery; import com.j256.ormlite.stmt.PreparedQuery;
import com.j256.ormlite.stmt.QueryBuilder; import com.j256.ormlite.stmt.QueryBuilder;
import com.squareup.otto.Subscribe;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -16,10 +17,10 @@ import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.Iob; import info.nightscout.androidaps.data.Iob;
import info.nightscout.androidaps.db.Treatment; import info.nightscout.androidaps.db.Treatment;
import info.nightscout.androidaps.events.EventTreatmentChange;
import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.TreatmentsInterface; import info.nightscout.androidaps.interfaces.TreatmentsInterface;
import info.nightscout.androidaps.plugins.OpenAPSMA.IobTotal; import info.nightscout.androidaps.plugins.OpenAPSMA.IobTotal;
import info.nightscout.androidaps.plugins.Treatments.events.EventTreatmentsUpdateGui;
import info.nightscout.client.data.NSProfile; import info.nightscout.client.data.NSProfile;
/** /**
@ -79,7 +80,6 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
public TreatmentsPlugin() { public TreatmentsPlugin() {
MainApp.bus().register(this); MainApp.bus().register(this);
initializeData(); initializeData();
MainApp.bus().post(new EventTreatmentsUpdateGui());
} }
public void initializeData() { public void initializeData() {
@ -171,5 +171,10 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
return treatments; return treatments;
} }
@Subscribe
public void onStatusEvent(final EventTreatmentChange ev) {
initializeData();
updateTotalIOB();
}
} }

View file

@ -1,7 +0,0 @@
package info.nightscout.androidaps.plugins.Treatments.events;
/**
* Created by mike on 05.08.2016.
*/
public class EventTreatmentsUpdateGui {
}