optimize refreshing gui

This commit is contained in:
Milos Kozak 2017-06-16 08:37:07 +02:00
parent 43231cc362
commit 49ef46936b
18 changed files with 58 additions and 71 deletions

View file

@ -94,7 +94,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
public void run() { public void run() {
recreate(); recreate();
try { // activity may be destroyed try { // activity may be destroyed
setUpTabs(ev.isSwitchToLast()); setUpTabs(true);
} catch (IllegalStateException e) { } catch (IllegalStateException e) {
e.printStackTrace(); e.printStackTrace();
} }

View file

@ -43,10 +43,10 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
String lang = sharedPreferences.getString("language", "en"); String lang = sharedPreferences.getString("language", "en");
LocaleHelper.setLocale(getApplicationContext(), lang); LocaleHelper.setLocale(getApplicationContext(), lang);
recreate(); recreate();
MainApp.bus().post(new EventRefreshGui(true)); MainApp.bus().post(new EventRefreshGui());
} }
if (key.equals("short_tabtitles")) { if (key.equals("short_tabtitles")) {
MainApp.bus().post(new EventRefreshGui(true)); MainApp.bus().post(new EventRefreshGui());
} }
updatePrefSummary(myPreferenceFragment.getPreference(key)); updatePrefSummary(myPreferenceFragment.getPreference(key));
} }

View file

@ -35,7 +35,7 @@ import info.nightscout.androidaps.events.EventCareportalEventChange;
import info.nightscout.androidaps.events.EventExtendedBolusChange; import info.nightscout.androidaps.events.EventExtendedBolusChange;
import info.nightscout.androidaps.events.EventNewBG; import info.nightscout.androidaps.events.EventNewBG;
import info.nightscout.androidaps.events.EventProfileSwitchChange; import info.nightscout.androidaps.events.EventProfileSwitchChange;
import info.nightscout.androidaps.events.EventRefreshGui; import info.nightscout.androidaps.events.EventRefreshOverview;
import info.nightscout.androidaps.events.EventReloadProfileSwitchData; import info.nightscout.androidaps.events.EventReloadProfileSwitchData;
import info.nightscout.androidaps.events.EventReloadTempBasalData; import info.nightscout.androidaps.events.EventReloadTempBasalData;
import info.nightscout.androidaps.events.EventReloadTreatmentData; import info.nightscout.androidaps.events.EventReloadTreatmentData;
@ -215,7 +215,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
new java.util.TimerTask() { new java.util.TimerTask() {
@Override @Override
public void run() { public void run() {
MainApp.bus().post(new EventRefreshGui(false)); MainApp.bus().post(new EventRefreshOverview("resetDatabases"));
} }
}, },
3000 3000

View file

@ -4,15 +4,4 @@ package info.nightscout.androidaps.events;
* Created by mike on 13.06.2016. * Created by mike on 13.06.2016.
*/ */
public class EventRefreshGui { public class EventRefreshGui {
public boolean isSwitchToLast() {
return switchToLast;
}
private final boolean switchToLast;
public EventRefreshGui(boolean switchToLast){
this.switchToLast = switchToLast;
}
} }

View file

@ -0,0 +1,13 @@
package info.nightscout.androidaps.events;
/**
* Created by mike on 16.06.2017.
*/
public class EventRefreshOverview {
public String from;
public EventRefreshOverview(String from) {
this.from = from;
}
}

View file

@ -16,15 +16,13 @@ import com.crashlytics.android.answers.Answers;
import com.crashlytics.android.answers.CustomEvent; import com.crashlytics.android.answers.CustomEvent;
import com.squareup.otto.Subscribe; import com.squareup.otto.Subscribe;
import java.util.Date;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
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.ExtendedBolus; import info.nightscout.androidaps.db.ExtendedBolus;
import info.nightscout.androidaps.events.EventExtendedBolusChange; import info.nightscout.androidaps.events.EventExtendedBolusChange;
import info.nightscout.androidaps.events.EventInitializationChanged; import info.nightscout.androidaps.events.EventInitializationChanged;
import info.nightscout.androidaps.events.EventRefreshGui; import info.nightscout.androidaps.events.EventRefreshOverview;
import info.nightscout.androidaps.events.EventTempBasalChange; import info.nightscout.androidaps.events.EventTempBasalChange;
import info.nightscout.androidaps.interfaces.PumpInterface; import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.plugins.Actions.dialogs.FillDialog; import info.nightscout.androidaps.plugins.Actions.dialogs.FillDialog;
@ -33,7 +31,6 @@ import info.nightscout.androidaps.plugins.Actions.dialogs.NewTempBasalDialog;
import info.nightscout.androidaps.plugins.Careportal.CareportalFragment; import info.nightscout.androidaps.plugins.Careportal.CareportalFragment;
import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog; import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog;
import info.nightscout.androidaps.plugins.Careportal.OptionsToShow; import info.nightscout.androidaps.plugins.Careportal.OptionsToShow;
import info.nightscout.androidaps.plugins.PumpDanaRv2.DanaRv2Plugin;
/** /**
* A simple {@link Fragment} subclass. * A simple {@link Fragment} subclass.
@ -107,7 +104,7 @@ public class ActionsFragment extends Fragment implements View.OnClickListener {
} }
@Subscribe @Subscribe
public void onStatusEvent(final EventRefreshGui ev) { public void onStatusEvent(final EventRefreshOverview ev) {
updateGUIIfVisible(); updateGUIIfVisible();
} }

View file

@ -234,7 +234,7 @@ public class ConfigBuilderFragment extends Fragment {
plugin.setFragmentVisible(type, cb.isChecked()); plugin.setFragmentVisible(type, cb.isChecked());
onEnabledCategoryChanged(plugin, type); onEnabledCategoryChanged(plugin, type);
configBuilderPlugin.storeSettings(); configBuilderPlugin.storeSettings();
MainApp.bus().post(new EventRefreshGui(true)); MainApp.bus().post(new EventRefreshGui());
MainApp.bus().post(new EventConfigBuilderChange()); MainApp.bus().post(new EventConfigBuilderChange());
getPlugin().logPluginStatus(); getPlugin().logPluginStatus();
Answers.getInstance().logCustom(new CustomEvent("ConfigurationChange")); Answers.getInstance().logCustom(new CustomEvent("ConfigurationChange"));
@ -247,7 +247,7 @@ public class ConfigBuilderFragment extends Fragment {
PluginBase plugin = (PluginBase) cb.getTag(); PluginBase plugin = (PluginBase) cb.getTag();
plugin.setFragmentVisible(type, cb.isChecked()); plugin.setFragmentVisible(type, cb.isChecked());
configBuilderPlugin.storeSettings(); configBuilderPlugin.storeSettings();
MainApp.bus().post(new EventRefreshGui(true)); MainApp.bus().post(new EventRefreshGui());
getPlugin().logPluginStatus(); getPlugin().logPluginStatus();
} }
}); });

View file

@ -44,17 +44,17 @@ import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.DetailedBolusInfo; import info.nightscout.androidaps.data.DetailedBolusInfo;
import info.nightscout.androidaps.data.IobTotal; import info.nightscout.androidaps.data.IobTotal;
import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.data.ProfileStore;
import info.nightscout.androidaps.data.PumpEnactResult; import info.nightscout.androidaps.data.PumpEnactResult;
import info.nightscout.androidaps.db.BgReading; import info.nightscout.androidaps.db.BgReading;
import info.nightscout.androidaps.db.CareportalEvent; import info.nightscout.androidaps.db.CareportalEvent;
import info.nightscout.androidaps.db.DatabaseHelper; import info.nightscout.androidaps.db.DatabaseHelper;
import info.nightscout.androidaps.db.Source; import info.nightscout.androidaps.db.Source;
import info.nightscout.androidaps.events.EventNewBG; import info.nightscout.androidaps.events.EventNewBG;
import info.nightscout.androidaps.events.EventRefreshGui; import info.nightscout.androidaps.events.EventRefreshOverview;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.Loop.LoopPlugin; import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.data.ProfileStore;
import info.nightscout.androidaps.plugins.OpenAPSAMA.OpenAPSAMAPlugin; import info.nightscout.androidaps.plugins.OpenAPSAMA.OpenAPSAMAPlugin;
import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateGui; import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateGui;
import info.nightscout.utils.BolusWizard; import info.nightscout.utils.BolusWizard;
@ -318,7 +318,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
final LoopPlugin activeloop = MainApp.getConfigBuilder().getActiveLoop(); final LoopPlugin activeloop = MainApp.getConfigBuilder().getActiveLoop();
if (activeloop != null) { if (activeloop != null) {
activeloop.superBolusTo(System.currentTimeMillis() + 2 * 60L * 60 * 1000); activeloop.superBolusTo(System.currentTimeMillis() + 2 * 60L * 60 * 1000);
MainApp.bus().post(new EventRefreshGui(false)); MainApp.bus().post(new EventRefreshOverview("WizardDialog"));
} }
result = pump.setTempBasalAbsolute(0d, 120); result = pump.setTempBasalAbsolute(0d, 120);
if (!result.success) { if (!result.success) {

View file

@ -45,13 +45,14 @@ public class NotificationStore {
Collections.sort(store, new NotificationComparator()); Collections.sort(store, new NotificationComparator());
} }
public void remove(int id) { public boolean remove(int id) {
for (int i = 0; i < store.size(); i++) { for (int i = 0; i < store.size(); i++) {
if (get(i).id == id) { if (get(i).id == id) {
store.remove(i); store.remove(i);
return; return true;
} }
} }
return false;
} }
public void removeExpired() { public void removeExpired() {

View file

@ -84,7 +84,7 @@ import info.nightscout.androidaps.events.EventExtendedBolusChange;
import info.nightscout.androidaps.events.EventInitializationChanged; import info.nightscout.androidaps.events.EventInitializationChanged;
import info.nightscout.androidaps.events.EventPreferenceChange; import info.nightscout.androidaps.events.EventPreferenceChange;
import info.nightscout.androidaps.events.EventPumpStatusChanged; import info.nightscout.androidaps.events.EventPumpStatusChanged;
import info.nightscout.androidaps.events.EventRefreshGui; import info.nightscout.androidaps.events.EventRefreshOverview;
import info.nightscout.androidaps.events.EventTempBasalChange; import info.nightscout.androidaps.events.EventTempBasalChange;
import info.nightscout.androidaps.events.EventTempTargetChange; import info.nightscout.androidaps.events.EventTempTargetChange;
import info.nightscout.androidaps.events.EventTreatmentChange; import info.nightscout.androidaps.events.EventTreatmentChange;
@ -107,7 +107,6 @@ import info.nightscout.androidaps.plugins.Overview.Dialogs.CalibrationDialog;
import info.nightscout.androidaps.plugins.Overview.Dialogs.NewTreatmentDialog; import info.nightscout.androidaps.plugins.Overview.Dialogs.NewTreatmentDialog;
import info.nightscout.androidaps.plugins.Overview.Dialogs.WizardDialog; import info.nightscout.androidaps.plugins.Overview.Dialogs.WizardDialog;
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification; import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
import info.nightscout.androidaps.plugins.Overview.graphExtensions.AreaGraphSeries; import info.nightscout.androidaps.plugins.Overview.graphExtensions.AreaGraphSeries;
import info.nightscout.androidaps.plugins.Overview.graphExtensions.DataPointWithLabelInterface; import info.nightscout.androidaps.plugins.Overview.graphExtensions.DataPointWithLabelInterface;
import info.nightscout.androidaps.plugins.Overview.graphExtensions.DoubleDataPoint; import info.nightscout.androidaps.plugins.Overview.graphExtensions.DoubleDataPoint;
@ -759,8 +758,8 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
} }
@Subscribe @Subscribe
public void onStatusEvent(final EventRefreshGui ev) { public void onStatusEvent(final EventRefreshOverview ev) {
scheduleUpdateGUI("EventRefreshGui"); scheduleUpdateGUI(ev.from);
} }
@Subscribe @Subscribe
@ -810,16 +809,6 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
scheduleUpdateGUI("EventTempTargetChange"); scheduleUpdateGUI("EventTempTargetChange");
} }
@Subscribe
public void onStatusEvent(final EventNewNotification n) {
updateNotifications();
}
@Subscribe
public void onStatusEvent(final EventDismissNotification n) {
updateNotifications();
}
@Subscribe @Subscribe
public void onStatusEvent(final EventPumpStatusChanged s) { public void onStatusEvent(final EventPumpStatusChanged s) {
Activity activity = getActivity(); Activity activity = getActivity();
@ -1608,6 +1597,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
RecyclerViewAdapter(List<Notification> notificationsList) { RecyclerViewAdapter(List<Notification> notificationsList) {
this.notificationsList = notificationsList; this.notificationsList = notificationsList;
log.debug("RecyclerViewAdapter");
} }
@Override @Override

View file

@ -7,6 +7,7 @@ import org.json.JSONException;
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.EventRefreshOverview;
import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification; import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
@ -99,11 +100,13 @@ public class OverviewPlugin implements PluginBase {
@Subscribe @Subscribe
public void onStatusEvent(final EventNewNotification n) { public void onStatusEvent(final EventNewNotification n) {
notificationStore.add(n.notification); notificationStore.add(n.notification);
MainApp.bus().post(new EventRefreshOverview("EventNewNotification"));
} }
@Subscribe @Subscribe
public void onStatusEvent(final EventDismissNotification n) { public void onStatusEvent(final EventDismissNotification n) {
notificationStore.remove(n.id); if (notificationStore.remove(n.id))
MainApp.bus().post(new EventRefreshOverview("EventDismissNotification"));
} }
} }

View file

@ -11,8 +11,6 @@ import android.support.v7.app.NotificationCompat;
import com.squareup.otto.Subscribe; import com.squareup.otto.Subscribe;
import java.util.Date;
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;
@ -27,12 +25,11 @@ import info.nightscout.androidaps.events.EventInitializationChanged;
import info.nightscout.androidaps.events.EventNewBG; import info.nightscout.androidaps.events.EventNewBG;
import info.nightscout.androidaps.events.EventNewBasalProfile; import info.nightscout.androidaps.events.EventNewBasalProfile;
import info.nightscout.androidaps.events.EventPreferenceChange; import info.nightscout.androidaps.events.EventPreferenceChange;
import info.nightscout.androidaps.events.EventRefreshGui; import info.nightscout.androidaps.events.EventRefreshOverview;
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.PluginBase; import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.PumpInterface; import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.data.Profile;
import info.nightscout.utils.DecimalFormatter; import info.nightscout.utils.DecimalFormatter;
/** /**
@ -258,7 +255,7 @@ public class PersistentNotificationPlugin implements PluginBase {
} }
@Subscribe @Subscribe
public void onStatusEvent(final EventRefreshGui ev) { public void onStatusEvent(final EventRefreshOverview ev) {
updateNotification(); updateNotification();
} }

View file

@ -8,7 +8,7 @@ import java.util.Date;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
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.EventRefreshGui; import info.nightscout.androidaps.events.EventRefreshOverview;
import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPlugin; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPlugin;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
@ -41,7 +41,7 @@ public class MsgInitConnStatusTime extends MessageBase {
} }
MainApp.getConfigBuilder().storeSettings(); MainApp.getConfigBuilder().storeSettings();
MainApp.bus().post(new EventRefreshGui(false)); MainApp.bus().post(new EventRefreshOverview("MsgInitConnStatusTime"));
return; return;
} }

View file

@ -8,7 +8,7 @@ import java.util.Date;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
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.EventRefreshGui; import info.nightscout.androidaps.events.EventRefreshOverview;
import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPlugin; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPlugin;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
@ -43,7 +43,7 @@ public class MsgInitConnStatusTime_k extends MessageBase {
} }
MainApp.getConfigBuilder().storeSettings(); MainApp.getConfigBuilder().storeSettings();
MainApp.bus().post(new EventRefreshGui(false)); MainApp.bus().post(new EventRefreshOverview("MsgInitConnStatusTime_k"));
return; return;
} }

View file

@ -6,7 +6,7 @@ import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
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.EventRefreshGui; import info.nightscout.androidaps.events.EventRefreshOverview;
import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPlugin; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPlugin;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
@ -57,7 +57,7 @@ public class MsgCheckValue_v2 extends MessageBase {
} }
MainApp.getConfigBuilder().storeSettings(); MainApp.getConfigBuilder().storeSettings();
MainApp.bus().post(new EventRefreshGui(false)); MainApp.bus().post(new EventRefreshOverview("MsgCheckValue_v2"));
return; return;
} }
if (Config.logDanaMessageDetail) { if (Config.logDanaMessageDetail) {

View file

@ -24,21 +24,21 @@ import info.nightscout.androidaps.Services.Intents;
import info.nightscout.androidaps.data.DetailedBolusInfo; import info.nightscout.androidaps.data.DetailedBolusInfo;
import info.nightscout.androidaps.data.GlucoseStatus; import info.nightscout.androidaps.data.GlucoseStatus;
import info.nightscout.androidaps.data.IobTotal; import info.nightscout.androidaps.data.IobTotal;
import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.data.PumpEnactResult; import info.nightscout.androidaps.data.PumpEnactResult;
import info.nightscout.androidaps.db.BgReading; import info.nightscout.androidaps.db.BgReading;
import info.nightscout.androidaps.db.DatabaseHelper; import info.nightscout.androidaps.db.DatabaseHelper;
import info.nightscout.androidaps.db.Source; import info.nightscout.androidaps.db.Source;
import info.nightscout.androidaps.events.EventPreferenceChange; import info.nightscout.androidaps.events.EventPreferenceChange;
import info.nightscout.androidaps.events.EventRefreshGui; import info.nightscout.androidaps.events.EventRefreshOverview;
import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.PumpInterface; import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPlugin;
import info.nightscout.androidaps.plugins.PumpDanaRKorean.DanaRKoreanPlugin;
import info.nightscout.androidaps.plugins.Loop.LoopPlugin; import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
import info.nightscout.androidaps.plugins.Overview.Notification; import info.nightscout.androidaps.plugins.Overview.Notification;
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPlugin;
import info.nightscout.androidaps.plugins.PumpDanaRKorean.DanaRKoreanPlugin;
import info.nightscout.androidaps.plugins.SmsCommunicator.events.EventNewSMS; import info.nightscout.androidaps.plugins.SmsCommunicator.events.EventNewSMS;
import info.nightscout.androidaps.plugins.SmsCommunicator.events.EventSmsCommunicatorUpdateGui; import info.nightscout.androidaps.plugins.SmsCommunicator.events.EventSmsCommunicatorUpdateGui;
import info.nightscout.utils.DecimalFormatter; import info.nightscout.utils.DecimalFormatter;
@ -273,7 +273,7 @@ public class SmsCommunicatorPlugin implements PluginBase {
if (loopPlugin != null && loopPlugin.isEnabled(PluginBase.LOOP)) { if (loopPlugin != null && loopPlugin.isEnabled(PluginBase.LOOP)) {
loopPlugin.setFragmentEnabled(PluginBase.LOOP, false); loopPlugin.setFragmentEnabled(PluginBase.LOOP, false);
PumpEnactResult result = MainApp.getConfigBuilder().cancelTempBasal(); PumpEnactResult result = MainApp.getConfigBuilder().cancelTempBasal();
MainApp.bus().post(new EventRefreshGui(false)); MainApp.bus().post(new EventRefreshOverview("SMS_LOOP_STOP"));
reply = MainApp.sResources.getString(R.string.smscommunicator_loophasbeendisabled)+ " " + reply = MainApp.sResources.getString(R.string.smscommunicator_loophasbeendisabled)+ " " +
MainApp.sResources.getString(result.success?R.string.smscommunicator_tempbasalcanceled:R.string.smscommunicator_tempbasalcancelfailed); MainApp.sResources.getString(result.success?R.string.smscommunicator_tempbasalcanceled:R.string.smscommunicator_tempbasalcancelfailed);
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date())); sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
@ -288,6 +288,7 @@ public class SmsCommunicatorPlugin implements PluginBase {
loopPlugin.setFragmentEnabled(PluginBase.LOOP, true); loopPlugin.setFragmentEnabled(PluginBase.LOOP, true);
reply = MainApp.sResources.getString(R.string.smscommunicator_loophasbeenenabled); reply = MainApp.sResources.getString(R.string.smscommunicator_loophasbeenenabled);
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date())); sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
MainApp.bus().post(new EventRefreshOverview("SMS_LOOP_START"));
} }
receivedSms.processed = true; receivedSms.processed = true;
Answers.getInstance().logCustom(new CustomEvent("SMS_Loop_Start")); Answers.getInstance().logCustom(new CustomEvent("SMS_Loop_Start"));
@ -311,7 +312,7 @@ public class SmsCommunicatorPlugin implements PluginBase {
case "RESUME": case "RESUME":
final LoopPlugin activeloop = ConfigBuilderPlugin.getActiveLoop(); final LoopPlugin activeloop = ConfigBuilderPlugin.getActiveLoop();
activeloop.suspendTo(0); activeloop.suspendTo(0);
MainApp.bus().post(new EventRefreshGui(false)); MainApp.bus().post(new EventRefreshOverview("SMS_LOOP_RESUME"));
NSUpload.uploadOpenAPSOffline(0); NSUpload.uploadOpenAPSOffline(0);
reply = MainApp.sResources.getString(R.string.smscommunicator_loopresumed); reply = MainApp.sResources.getString(R.string.smscommunicator_loopresumed);
sendSMSToAllNumbers(new Sms(receivedSms.phoneNumber, reply, new Date())); sendSMSToAllNumbers(new Sms(receivedSms.phoneNumber, reply, new Date()));
@ -536,7 +537,7 @@ public class SmsCommunicatorPlugin implements PluginBase {
activeloop.suspendTo(System.currentTimeMillis() + suspendWaitingForConfirmation.duration * 60L * 1000); activeloop.suspendTo(System.currentTimeMillis() + suspendWaitingForConfirmation.duration * 60L * 1000);
PumpEnactResult result = MainApp.getConfigBuilder().cancelTempBasal(); PumpEnactResult result = MainApp.getConfigBuilder().cancelTempBasal();
NSUpload.uploadOpenAPSOffline(suspendWaitingForConfirmation.duration * 60); NSUpload.uploadOpenAPSOffline(suspendWaitingForConfirmation.duration * 60);
MainApp.bus().post(new EventRefreshGui(false)); MainApp.bus().post(new EventRefreshOverview("SMS_LOOP_SUSPENDED"));
reply = MainApp.sResources.getString(R.string.smscommunicator_loopsuspended) + " " + reply = MainApp.sResources.getString(R.string.smscommunicator_loopsuspended) + " " +
MainApp.sResources.getString(result.success?R.string.smscommunicator_tempbasalcanceled:R.string.smscommunicator_tempbasalcancelfailed); MainApp.sResources.getString(result.success?R.string.smscommunicator_tempbasalcanceled:R.string.smscommunicator_tempbasalcancelfailed);
sendSMSToAllNumbers(new Sms(receivedSms.phoneNumber, reply, new Date())); sendSMSToAllNumbers(new Sms(receivedSms.phoneNumber, reply, new Date()));

View file

@ -13,16 +13,14 @@ import info.nightscout.androidaps.events.EventExtendedBolusChange;
import info.nightscout.androidaps.events.EventNewBG; import info.nightscout.androidaps.events.EventNewBG;
import info.nightscout.androidaps.events.EventNewBasalProfile; import info.nightscout.androidaps.events.EventNewBasalProfile;
import info.nightscout.androidaps.events.EventPreferenceChange; import info.nightscout.androidaps.events.EventPreferenceChange;
import info.nightscout.androidaps.events.EventRefreshGui; import info.nightscout.androidaps.events.EventRefreshOverview;
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.PluginBase; import info.nightscout.androidaps.interfaces.PluginBase;
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.Overview.events.EventDismissBolusprogressIfRunning; import info.nightscout.androidaps.plugins.Overview.events.EventDismissBolusprogressIfRunning;
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress; import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
import info.nightscout.androidaps.plugins.Wear.wearintegration.WatchUpdaterService; import info.nightscout.androidaps.plugins.Wear.wearintegration.WatchUpdaterService;
import info.nightscout.utils.ToastUtils;
/** /**
* Created by adrian on 17/11/16. * Created by adrian on 17/11/16.
@ -166,7 +164,7 @@ public class WearPlugin implements PluginBase {
} }
@Subscribe @Subscribe
public void onStatusEvent(final EventRefreshGui ev) { public void onStatusEvent(final EventRefreshOverview ev) {
LoopPlugin activeloop = MainApp.getConfigBuilder().getActiveLoop(); LoopPlugin activeloop = MainApp.getConfigBuilder().getActiveLoop();
if (activeloop == null) return; if (activeloop == null) return;

View file

@ -9,23 +9,21 @@ import android.support.annotation.NonNull;
import com.squareup.otto.Subscribe; import com.squareup.otto.Subscribe;
import java.util.Date;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
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.IobTotal; import info.nightscout.androidaps.data.IobTotal;
import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.db.TemporaryBasal; import info.nightscout.androidaps.db.TemporaryBasal;
import info.nightscout.androidaps.events.EventExtendedBolusChange; import info.nightscout.androidaps.events.EventExtendedBolusChange;
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.EventRefreshOverview;
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.PluginBase; import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.TreatmentsInterface; import info.nightscout.androidaps.interfaces.TreatmentsInterface;
import info.nightscout.androidaps.plugins.Loop.LoopPlugin; import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
import info.nightscout.androidaps.data.Profile;
import info.nightscout.utils.DecimalFormatter; import info.nightscout.utils.DecimalFormatter;
/** /**
@ -227,7 +225,7 @@ public class StatuslinePlugin implements PluginBase {
} }
@Subscribe @Subscribe
public void onStatusEvent(final EventRefreshGui ev) { public void onStatusEvent(final EventRefreshOverview ev) {
//Filter events where loop is (de)activated //Filter events where loop is (de)activated