fixing bugs after refactoring
This commit is contained in:
parent
12b014afd4
commit
294f9d6c99
13 changed files with 150 additions and 164 deletions
|
@ -107,10 +107,10 @@ public class DataService extends IntentService {
|
|||
} else if (Telephony.Sms.Intents.SMS_RECEIVED_ACTION.equals(action)) {
|
||||
handleNewSMS(intent);
|
||||
}
|
||||
DataReceiver.completeWakefulIntent(intent);
|
||||
}
|
||||
if (Config.logFunctionCalls)
|
||||
log.debug("onHandleIntent exit");
|
||||
log.debug("onHandleIntent exit " + intent);
|
||||
DataReceiver.completeWakefulIntent(intent);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -28,9 +28,6 @@ import java.util.List;
|
|||
import info.nightscout.androidaps.Constants;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
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.Round;
|
||||
|
||||
|
@ -218,13 +215,13 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
|||
|
||||
@Override
|
||||
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.avgdelta) + " " + DecimalFormatter.to2Decimal(avgdelta) + " mg/dl";
|
||||
}
|
||||
|
||||
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.avgdelta) + "</b>: " + DecimalFormatter.to2Decimal(avgdelta) + " mg/dl");
|
||||
}
|
||||
|
@ -240,6 +237,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
|||
dest.writeDouble(delta);
|
||||
dest.writeDouble(glucose);
|
||||
}
|
||||
|
||||
public final Parcelable.Creator<GlucoseStatus> CREATOR = new Parcelable.Creator<GlucoseStatus>() {
|
||||
public GlucoseStatus createFromParcel(Parcel in) {
|
||||
return new GlucoseStatus(in);
|
||||
|
@ -256,7 +254,8 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
|||
glucose = in.readDouble();
|
||||
}
|
||||
|
||||
public GlucoseStatus() {}
|
||||
public GlucoseStatus() {
|
||||
}
|
||||
|
||||
public GlucoseStatus(Double glucose, Double delta, Double avgdelta) {
|
||||
this.glucose = glucose;
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
package info.nightscout.androidaps.events;
|
||||
|
||||
/**
|
||||
* Created by mike on 25.06.2016.
|
||||
*/
|
||||
public class EventRefreshOpenLoop {
|
||||
}
|
|
@ -655,16 +655,22 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
|
|||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventNewBG ev) {
|
||||
// Give some time to Loop
|
||||
try {
|
||||
Thread.sleep(120 * 1000L);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
// if status not uploaded, upload pump status only
|
||||
if (new Date().getTime() - lastDeviceStatusUpload.getTime() > 120 * 1000L) {
|
||||
uploadDeviceStatus();
|
||||
}
|
||||
Thread t = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// Give some time to Loop
|
||||
try {
|
||||
Thread.sleep(120 * 1000L);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
// 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) {
|
||||
|
|
|
@ -12,16 +12,18 @@ import android.support.v7.app.NotificationCompat;
|
|||
|
||||
import com.squareup.otto.Subscribe;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import info.nightscout.androidaps.Config;
|
||||
import info.nightscout.androidaps.Constants;
|
||||
import info.nightscout.androidaps.MainActivity;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||
import info.nightscout.androidaps.events.EventNewBG;
|
||||
import info.nightscout.androidaps.events.EventRefreshOpenLoop;
|
||||
import info.nightscout.androidaps.events.EventTreatmentChange;
|
||||
import info.nightscout.androidaps.interfaces.APSInterface;
|
||||
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.Loop.events.EventLoopSetLastRunGui;
|
||||
import info.nightscout.androidaps.plugins.Loop.events.EventLoopUpdateGui;
|
||||
import info.nightscout.androidaps.plugins.Loop.events.EventNewOpenLoopNotification;
|
||||
|
||||
/**
|
||||
* Created by mike on 05.08.2016.
|
||||
*/
|
||||
public class LoopPlugin implements PluginBase {
|
||||
private static Logger log = LoggerFactory.getLogger(LoopPlugin.class);
|
||||
|
||||
private static Handler sHandler;
|
||||
private static HandlerThread sHandlerThread;
|
||||
|
||||
|
@ -112,101 +117,108 @@ public class LoopPlugin implements PluginBase {
|
|||
}
|
||||
|
||||
public void invoke(boolean allowNotification) {
|
||||
ConstraintsInterface constraintsInterface = MainApp.getConfigBuilder();
|
||||
if (!constraintsInterface.isLoopEnabled()) {
|
||||
MainApp.bus().post(new EventLoopSetLastRunGui(MainApp.sResources.getString(R.string.loopdisabled)));
|
||||
return;
|
||||
}
|
||||
final ConfigBuilderPlugin configBuilder = MainApp.getConfigBuilder();
|
||||
APSResult result = null;
|
||||
try {
|
||||
if (Config.logFunctionCalls)
|
||||
log.debug("invoke");
|
||||
ConstraintsInterface constraintsInterface = MainApp.getConfigBuilder();
|
||||
if (!constraintsInterface.isLoopEnabled()) {
|
||||
MainApp.bus().post(new EventLoopSetLastRunGui(MainApp.sResources.getString(R.string.loopdisabled)));
|
||||
return;
|
||||
}
|
||||
final ConfigBuilderPlugin configBuilder = MainApp.getConfigBuilder();
|
||||
APSResult result = null;
|
||||
|
||||
if (configBuilder == null || !isEnabled(PluginBase.GENERAL))
|
||||
return;
|
||||
if (configBuilder == null || !isEnabled(PluginBase.GENERAL))
|
||||
return;
|
||||
|
||||
APSInterface usedAPS = configBuilder.getActiveAPS();
|
||||
if (usedAPS != null && ((PluginBase) usedAPS).isEnabled(PluginBase.APS)) {
|
||||
usedAPS.invoke();
|
||||
result = usedAPS.getLastAPSResult();
|
||||
}
|
||||
APSInterface usedAPS = configBuilder.getActiveAPS();
|
||||
if (usedAPS != null && ((PluginBase) usedAPS).isEnabled(PluginBase.APS)) {
|
||||
usedAPS.invoke();
|
||||
result = usedAPS.getLastAPSResult();
|
||||
}
|
||||
|
||||
// Check if we have any result
|
||||
if (result == null) {
|
||||
MainApp.bus().post(new EventLoopSetLastRunGui(MainApp.sResources.getString(R.string.noapsselected)));
|
||||
return;
|
||||
}
|
||||
// Check if we have any result
|
||||
if (result == null) {
|
||||
MainApp.bus().post(new EventLoopSetLastRunGui(MainApp.sResources.getString(R.string.noapsselected)));
|
||||
return;
|
||||
}
|
||||
|
||||
// check rate for constrais
|
||||
final APSResult resultAfterConstraints = result.clone();
|
||||
resultAfterConstraints.rate = constraintsInterface.applyBasalConstraints(resultAfterConstraints.rate);
|
||||
// check rate for constrais
|
||||
final APSResult resultAfterConstraints = result.clone();
|
||||
resultAfterConstraints.rate = constraintsInterface.applyBasalConstraints(resultAfterConstraints.rate);
|
||||
|
||||
if (lastRun == null) lastRun = new LastRun();
|
||||
lastRun.request = result;
|
||||
lastRun.constraintsProcessed = resultAfterConstraints;
|
||||
lastRun.lastAPSRun = new Date();
|
||||
lastRun.source = ((PluginBase) usedAPS).getName();
|
||||
lastRun.setByPump = null;
|
||||
if (lastRun == null) lastRun = new LastRun();
|
||||
lastRun.request = result;
|
||||
lastRun.constraintsProcessed = resultAfterConstraints;
|
||||
lastRun.lastAPSRun = new Date();
|
||||
lastRun.source = ((PluginBase) usedAPS).getName();
|
||||
lastRun.setByPump = null;
|
||||
|
||||
if (constraintsInterface.isClosedModeEnabled()) {
|
||||
if (result.changeRequested) {
|
||||
final PumpEnactResult waiting = new PumpEnactResult();
|
||||
final PumpEnactResult previousResult = lastRun.setByPump;
|
||||
waiting.queued = true;
|
||||
lastRun.setByPump = waiting;
|
||||
MainApp.bus().post(new EventLoopUpdateGui());
|
||||
sHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final PumpEnactResult applyResult = configBuilder.applyAPSRequest(resultAfterConstraints);
|
||||
if (applyResult.enacted) {
|
||||
lastRun.setByPump = applyResult;
|
||||
lastRun.lastEnact = lastRun.lastAPSRun;
|
||||
} else {
|
||||
lastRun.setByPump = previousResult;
|
||||
if (constraintsInterface.isClosedModeEnabled()) {
|
||||
if (result.changeRequested) {
|
||||
final PumpEnactResult waiting = new PumpEnactResult();
|
||||
final PumpEnactResult previousResult = lastRun.setByPump;
|
||||
waiting.queued = true;
|
||||
lastRun.setByPump = waiting;
|
||||
MainApp.bus().post(new EventLoopUpdateGui());
|
||||
sHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final PumpEnactResult applyResult = configBuilder.applyAPSRequest(resultAfterConstraints);
|
||||
if (applyResult.enacted) {
|
||||
lastRun.setByPump = applyResult;
|
||||
lastRun.lastEnact = lastRun.lastAPSRun;
|
||||
} else {
|
||||
lastRun.setByPump = previousResult;
|
||||
}
|
||||
MainApp.bus().post(new EventLoopUpdateGui());
|
||||
}
|
||||
MainApp.bus().post(new EventLoopUpdateGui());
|
||||
}
|
||||
});
|
||||
});
|
||||
} else {
|
||||
lastRun.setByPump = null;
|
||||
lastRun.source = null;
|
||||
}
|
||||
} else {
|
||||
lastRun.setByPump = null;
|
||||
lastRun.source = null;
|
||||
}
|
||||
} else {
|
||||
if (result.changeRequested && allowNotification) {
|
||||
NotificationCompat.Builder builder =
|
||||
new NotificationCompat.Builder(MainApp.instance().getApplicationContext());
|
||||
builder.setSmallIcon(R.drawable.notification_icon)
|
||||
.setContentTitle(MainApp.sResources.getString(R.string.openloop_newsuggestion))
|
||||
.setContentText(resultAfterConstraints.toString())
|
||||
.setAutoCancel(true)
|
||||
.setPriority(Notification.PRIORITY_HIGH)
|
||||
.setCategory(Notification.CATEGORY_ALARM)
|
||||
.setVisibility(Notification.VISIBILITY_PUBLIC);
|
||||
if (result.changeRequested && allowNotification) {
|
||||
NotificationCompat.Builder builder =
|
||||
new NotificationCompat.Builder(MainApp.instance().getApplicationContext());
|
||||
builder.setSmallIcon(R.drawable.notification_icon)
|
||||
.setContentTitle(MainApp.sResources.getString(R.string.openloop_newsuggestion))
|
||||
.setContentText(resultAfterConstraints.toString())
|
||||
.setAutoCancel(true)
|
||||
.setPriority(Notification.PRIORITY_HIGH)
|
||||
.setCategory(Notification.CATEGORY_ALARM)
|
||||
.setVisibility(Notification.VISIBILITY_PUBLIC);
|
||||
|
||||
// Creates an explicit intent for an Activity in your app
|
||||
Intent resultIntent = new Intent(MainApp.instance().getApplicationContext(), MainActivity.class);
|
||||
// Creates an explicit intent for an Activity in your app
|
||||
Intent resultIntent = new Intent(MainApp.instance().getApplicationContext(), MainActivity.class);
|
||||
|
||||
// The stack builder object will contain an artificial back stack for the
|
||||
// started Activity.
|
||||
// This ensures that navigating backward from the Activity leads out of
|
||||
// your application to the Home screen.
|
||||
TaskStackBuilder stackBuilder = TaskStackBuilder.create(MainApp.instance().getApplicationContext());
|
||||
stackBuilder.addParentStack(MainActivity.class);
|
||||
// Adds the Intent that starts the Activity to the top of the stack
|
||||
stackBuilder.addNextIntent(resultIntent);
|
||||
PendingIntent resultPendingIntent =
|
||||
stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
builder.setContentIntent(resultPendingIntent);
|
||||
builder.setVibrate(new long[]{1000, 1000, 1000, 1000, 1000});
|
||||
NotificationManager mNotificationManager =
|
||||
(NotificationManager) MainApp.instance().getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
// mId allows you to update the notification later on.
|
||||
mNotificationManager.notify(Constants.notificationID, builder.build());
|
||||
MainApp.bus().post(new EventRefreshOpenLoop());
|
||||
// The stack builder object will contain an artificial back stack for the
|
||||
// started Activity.
|
||||
// This ensures that navigating backward from the Activity leads out of
|
||||
// your application to the Home screen.
|
||||
TaskStackBuilder stackBuilder = TaskStackBuilder.create(MainApp.instance().getApplicationContext());
|
||||
stackBuilder.addParentStack(MainActivity.class);
|
||||
// Adds the Intent that starts the Activity to the top of the stack
|
||||
stackBuilder.addNextIntent(resultIntent);
|
||||
PendingIntent resultPendingIntent =
|
||||
stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
builder.setContentIntent(resultPendingIntent);
|
||||
builder.setVibrate(new long[]{1000, 1000, 1000, 1000, 1000});
|
||||
NotificationManager mNotificationManager =
|
||||
(NotificationManager) MainApp.instance().getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
// mId allows you to update the notification later on.
|
||||
mNotificationManager.notify(Constants.notificationID, builder.build());
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
package info.nightscout.androidaps.plugins.Loop.events;
|
||||
|
||||
/**
|
||||
* Created by mike on 07.08.2016.
|
||||
*/
|
||||
public class EventNewOpenLoopNotification {
|
||||
}
|
|
@ -48,11 +48,11 @@ import info.nightscout.androidaps.db.Treatment;
|
|||
import info.nightscout.androidaps.events.EventNewBG;
|
||||
import info.nightscout.androidaps.events.EventPreferenceChange;
|
||||
import info.nightscout.androidaps.events.EventRefreshGui;
|
||||
import info.nightscout.androidaps.events.EventRefreshOpenLoop;
|
||||
import info.nightscout.androidaps.events.EventTempBasalChange;
|
||||
import info.nightscout.androidaps.events.EventTreatmentChange;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
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.OpenAPSMA.IobTotal;
|
||||
import info.nightscout.androidaps.plugins.Overview.Dialogs.NewExtendedBolusDialog;
|
||||
|
@ -92,8 +92,8 @@ public class OverviewFragment extends Fragment {
|
|||
Button setExtenedButton;
|
||||
Button acceptTempButton;
|
||||
|
||||
private static Handler sLoopHandler = new Handler();
|
||||
private static Runnable sRefreshLoop = null;
|
||||
Handler sLoopHandler = new Handler();
|
||||
Runnable sRefreshLoop = null;
|
||||
|
||||
private static Handler sHandler;
|
||||
private static HandlerThread sHandlerThread;
|
||||
|
@ -114,21 +114,6 @@ public class OverviewFragment extends Fragment {
|
|||
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
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
|
@ -217,6 +202,7 @@ public class OverviewFragment extends Fragment {
|
|||
sHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
acceptTempLayout.setVisibility(View.GONE);
|
||||
PumpEnactResult applyResult = MainApp.getConfigBuilder().applyAPSRequest(finalLastRun.constraintsProcessed);
|
||||
if (applyResult.enacted) {
|
||||
finalLastRun.setByPump = applyResult;
|
||||
|
@ -249,12 +235,21 @@ public class OverviewFragment extends Fragment {
|
|||
public void onPause() {
|
||||
super.onPause();
|
||||
MainApp.bus().unregister(this);
|
||||
sLoopHandler.removeCallbacksAndMessages(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
MainApp.bus().register(this);
|
||||
sRefreshLoop = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
updateGUIIfVisible();
|
||||
sLoopHandler.postDelayed(sRefreshLoop, 60 * 1000L);
|
||||
}
|
||||
};
|
||||
sLoopHandler.postDelayed(sRefreshLoop, 60 * 1000L);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
|
@ -283,7 +278,7 @@ public class OverviewFragment extends Fragment {
|
|||
}
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventRefreshOpenLoop ev) {
|
||||
public void onStatusEvent(final EventNewOpenLoopNotification ev) {
|
||||
updateGUIIfVisible();
|
||||
}
|
||||
|
||||
|
|
|
@ -24,9 +24,9 @@ import java.util.List;
|
|||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.db.TempBasal;
|
||||
import info.nightscout.androidaps.events.EventTempBasalChange;
|
||||
import info.nightscout.androidaps.interfaces.FragmentBase;
|
||||
import info.nightscout.androidaps.plugins.OpenAPSMA.IobTotal;
|
||||
import info.nightscout.androidaps.plugins.TempBasals.events.EventTempBasalsUpdateGui;
|
||||
import info.nightscout.utils.DecimalFormatter;
|
||||
|
||||
|
||||
|
@ -163,9 +163,8 @@ public class TempBasalsFragment extends Fragment implements FragmentBase {
|
|||
MainApp.bus().register(this);
|
||||
}
|
||||
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventTempBasalsUpdateGui s) {
|
||||
public void onStatusEvent(final EventTempBasalChange ev) {
|
||||
updateGUI();
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,6 @@ import info.nightscout.androidaps.events.EventTempBasalChange;
|
|||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.TempBasalsInterface;
|
||||
import info.nightscout.androidaps.plugins.OpenAPSMA.IobTotal;
|
||||
import info.nightscout.androidaps.plugins.TempBasals.events.EventTempBasalsUpdateGui;
|
||||
|
||||
/**
|
||||
* Created by mike on 05.08.2016.
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.TempBasals.events;
|
||||
|
||||
/**
|
||||
* Created by mike on 05.08.2016.
|
||||
*/
|
||||
public class EventTempBasalsUpdateGui {
|
||||
}
|
|
@ -16,17 +16,12 @@ import android.widget.Button;
|
|||
import android.widget.LinearLayout;
|
||||
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 org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.text.DateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -37,12 +32,6 @@ import info.nightscout.androidaps.data.Iob;
|
|||
import info.nightscout.androidaps.db.Treatment;
|
||||
import info.nightscout.androidaps.events.EventTreatmentChange;
|
||||
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.utils.DecimalFormatter;
|
||||
|
||||
|
@ -185,10 +174,6 @@ public class TreatmentsFragment extends Fragment implements View.OnClickListener
|
|||
public void onResume() {
|
||||
super.onResume();
|
||||
MainApp.bus().register(this);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventTreatmentsUpdateGui ev) {
|
||||
updateGUI();
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ package info.nightscout.androidaps.plugins.Treatments;
|
|||
import com.j256.ormlite.dao.Dao;
|
||||
import com.j256.ormlite.stmt.PreparedQuery;
|
||||
import com.j256.ormlite.stmt.QueryBuilder;
|
||||
import com.squareup.otto.Subscribe;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -16,10 +17,10 @@ import info.nightscout.androidaps.MainApp;
|
|||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.data.Iob;
|
||||
import info.nightscout.androidaps.db.Treatment;
|
||||
import info.nightscout.androidaps.events.EventTreatmentChange;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
|
||||
import info.nightscout.androidaps.plugins.OpenAPSMA.IobTotal;
|
||||
import info.nightscout.androidaps.plugins.Treatments.events.EventTreatmentsUpdateGui;
|
||||
import info.nightscout.client.data.NSProfile;
|
||||
|
||||
/**
|
||||
|
@ -79,7 +80,6 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
|
|||
public TreatmentsPlugin() {
|
||||
MainApp.bus().register(this);
|
||||
initializeData();
|
||||
MainApp.bus().post(new EventTreatmentsUpdateGui());
|
||||
}
|
||||
|
||||
public void initializeData() {
|
||||
|
@ -171,5 +171,10 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
|
|||
return treatments;
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventTreatmentChange ev) {
|
||||
initializeData();
|
||||
updateTotalIOB();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.Treatments.events;
|
||||
|
||||
/**
|
||||
* Created by mike on 05.08.2016.
|
||||
*/
|
||||
public class EventTreatmentsUpdateGui {
|
||||
}
|
Loading…
Reference in a new issue