fixing bugs after refactoring
This commit is contained in:
parent
12b014afd4
commit
294f9d6c99
|
@ -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;
|
||||
|
||||
|
@ -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,6 +655,9 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
|
|||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventNewBG ev) {
|
||||
Thread t = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// Give some time to Loop
|
||||
try {
|
||||
Thread.sleep(120 * 1000L);
|
||||
|
@ -666,6 +669,9 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
|
|||
uploadDeviceStatus();
|
||||
}
|
||||
}
|
||||
});
|
||||
t.start();
|
||||
}
|
||||
|
||||
public void uploadTempBasalStartAbsolute(Double absolute, double durationInMinutes) {
|
||||
try {
|
||||
|
|
|
@ -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,6 +117,9 @@ public class LoopPlugin implements PluginBase {
|
|||
}
|
||||
|
||||
public void invoke(boolean allowNotification) {
|
||||
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)));
|
||||
|
@ -201,12 +209,16 @@ public class LoopPlugin implements PluginBase {
|
|||
(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());
|
||||
MainApp.bus().post(new EventNewOpenLoopNotification());
|
||||
}
|
||||
}
|
||||
|
||||
MainApp.bus().post(new EventLoopUpdateGui());
|
||||
MainApp.getConfigBuilder().uploadDeviceStatus();
|
||||
} finally {
|
||||
if (Config.logFunctionCalls)
|
||||
log.debug("invoke end");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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