Merge pull request #295 from jotomo/on-resume-update-gui

On resume update gui
This commit is contained in:
AdrianLxM 2017-07-21 16:47:28 +02:00 committed by GitHub
commit 3d82bdb347
23 changed files with 147 additions and 299 deletions

View file

@ -31,11 +31,12 @@ import info.nightscout.androidaps.plugins.Actions.dialogs.NewTempBasalDialog;
import info.nightscout.androidaps.plugins.Careportal.CareportalFragment;
import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog;
import info.nightscout.androidaps.plugins.Careportal.OptionsToShow;
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
/**
* A simple {@link Fragment} subclass.
*/
public class ActionsFragment extends Fragment implements View.OnClickListener {
public class ActionsFragment extends SubscriberFragment implements View.OnClickListener {
static ActionsPlugin actionsPlugin = new ActionsPlugin();
@ -82,43 +83,32 @@ public class ActionsFragment extends Fragment implements View.OnClickListener {
tempBasal.setOnClickListener(this);
fill.setOnClickListener(this);
updateGUIIfVisible();
updateGUI();
return view;
}
@Override
public void onPause() {
super.onPause();
MainApp.bus().unregister(this);
}
@Override
public void onResume() {
super.onResume();
MainApp.bus().register(this);
}
@Subscribe
public void onStatusEvent(final EventInitializationChanged ev) {
updateGUIIfVisible();
updateGUI();
}
@Subscribe
public void onStatusEvent(final EventRefreshOverview ev) {
updateGUIIfVisible();
updateGUI();
}
@Subscribe
public void onStatusEvent(final EventExtendedBolusChange ev) {
updateGUIIfVisible();
updateGUI();
}
@Subscribe
public void onStatusEvent(final EventTempBasalChange ev) {
updateGUIIfVisible();
updateGUI();
}
void updateGUIIfVisible() {
@Override
protected void updateGUI() {
Activity activity = getActivity();
if (activity != null)
activity.runOnUiThread(new Runnable() {

View file

@ -19,9 +19,10 @@ import info.nightscout.androidaps.R;
import info.nightscout.androidaps.db.CareportalEvent;
import info.nightscout.androidaps.events.EventCareportalEventChange;
import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog;
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
import info.nightscout.androidaps.plugins.Overview.OverviewFragment;
public class CareportalFragment extends Fragment implements View.OnClickListener {
public class CareportalFragment extends SubscriberFragment implements View.OnClickListener {
static CareportalPlugin careportalPlugin;
@ -178,24 +179,13 @@ public class CareportalFragment extends Fragment implements View.OnClickListener
newDialog.show(manager, "NewNSTreatmentDialog");
}
@Override
public void onPause() {
super.onPause();
MainApp.bus().unregister(this);
}
@Override
public void onResume() {
super.onResume();
MainApp.bus().register(this);
}
@Subscribe
public void onStatusEvent(final EventCareportalEventChange c) {
updateGUI();
}
void updateGUI() {
@Override
protected void updateGUI() {
Activity activity = getActivity();
updateAge(activity, sage, iage, cage, pbage);
}

View file

@ -0,0 +1,22 @@
package info.nightscout.androidaps.plugins.Common;
import android.support.v4.app.Fragment;
import info.nightscout.androidaps.MainApp;
abstract public class SubscriberFragment extends Fragment {
@Override
public void onPause() {
super.onPause();
MainApp.bus().unregister(this);
}
@Override
public void onResume() {
super.onResume();
MainApp.bus().register(this);
updateGUI();
}
protected abstract void updateGUI();
}

View file

@ -35,12 +35,22 @@ public class InsulinFastactingFragment extends Fragment {
insulinDia = (TextView) view.findViewById(R.id.insulin_dia);
insulinGraph = (ActivityGraph) view.findViewById(R.id.insuling_graph);
insulinName.setText(insulinFastactingPlugin.getFriendlyName());
insulinComment.setText(insulinFastactingPlugin.getComment());
insulinDia.setText(MainApp.sResources.getText(R.string.dia) + " " + new Double(insulinFastactingPlugin.getDia()).toString() + "h");
insulinGraph.show(insulinFastactingPlugin);
updateGUI();
return view;
}
@Override
public void onResume() {
super.onResume();
updateGUI();
}
private void updateGUI() {
insulinName.setText(insulinFastactingPlugin.getFriendlyName());
insulinComment.setText(insulinFastactingPlugin.getComment());
insulinDia.setText(MainApp.sResources.getText(R.string.dia) + " " + new Double(insulinFastactingPlugin.getDia()).toString() + "h");
insulinGraph.show(insulinFastactingPlugin);
}
}

View file

@ -36,12 +36,22 @@ public class InsulinFastactingProlongedFragment extends Fragment {
insulinDia = (TextView) view.findViewById(R.id.insulin_dia);
insulinGraph = (ActivityGraph) view.findViewById(R.id.insuling_graph);
insulinName.setText(insulinFastactingProlongedPlugin.getFriendlyName());
insulinComment.setText(insulinFastactingProlongedPlugin.getComment());
insulinDia.setText(MainApp.sResources.getText(R.string.dia) + " " + new Double(insulinFastactingProlongedPlugin.getDia()).toString() + "h");
insulinGraph.show(insulinFastactingProlongedPlugin);
updateGUI();
return view;
}
@Override
public void onResume() {
super.onResume();
updateGUI();
}
private void updateGUI() {
insulinName.setText(insulinFastactingProlongedPlugin.getFriendlyName());
insulinComment.setText(insulinFastactingProlongedPlugin.getComment());
insulinDia.setText(MainApp.sResources.getText(R.string.dia) + " " + new Double(insulinFastactingProlongedPlugin.getDia()).toString() + "h");
insulinGraph.show(insulinFastactingProlongedPlugin);
}
}

View file

@ -3,7 +3,6 @@ package info.nightscout.androidaps.plugins.Loop;
import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -19,10 +18,11 @@ import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
import info.nightscout.androidaps.plugins.Loop.events.EventLoopSetLastRunGui;
import info.nightscout.androidaps.plugins.Loop.events.EventLoopUpdateGui;
public class LoopFragment extends Fragment implements View.OnClickListener {
public class LoopFragment extends SubscriberFragment implements View.OnClickListener {
private static Logger log = LoggerFactory.getLogger(LoopFragment.class);
private static LoopPlugin loopPlugin;
@ -61,18 +61,6 @@ public class LoopFragment extends Fragment implements View.OnClickListener {
return view;
}
@Override
public void onPause() {
super.onPause();
MainApp.bus().unregister(this);
}
@Override
public void onResume() {
super.onResume();
MainApp.bus().register(this);
}
@Override
public void onClick(View view) {
switch (view.getId()) {
@ -110,7 +98,8 @@ public class LoopFragment extends Fragment implements View.OnClickListener {
}
void updateGUI() {
@Override
protected void updateGUI() {
Activity activity = getActivity();
if (activity != null)
activity.runOnUiThread(new Runnable() {

View file

@ -28,12 +28,13 @@ import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.events.EventPreferenceChange;
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientNewLog;
import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientRestart;
import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientUpdateGUI;
import info.nightscout.utils.SP;
public class NSClientInternalFragment extends Fragment implements View.OnClickListener, CompoundButton.OnCheckedChangeListener {
public class NSClientInternalFragment extends SubscriberFragment implements View.OnClickListener, CompoundButton.OnCheckedChangeListener {
private static Logger log = LoggerFactory.getLogger(NSClientInternalFragment.class);
static NSClientInternalPlugin nsClientInternalPlugin;
@ -150,25 +151,13 @@ public class NSClientInternalFragment extends Fragment implements View.OnClickLi
}
}
@Override
public void onPause() {
super.onPause();
MainApp.bus().unregister(this);
}
@Override
public void onResume() {
super.onResume();
MainApp.bus().register(this);
updateGUI();
}
@Subscribe
public void onStatusEvent(final EventNSClientUpdateGUI ev) {
updateGUI();
}
private void updateGUI() {
@Override
protected void updateGUI() {
Activity activity = getActivity();
if (activity != null)
activity.runOnUiThread(new Runnable() {

View file

@ -20,11 +20,12 @@ import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateGui;
import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateResultGui;
import info.nightscout.utils.JSONFormatter;
public class OpenAPSAMAFragment extends Fragment implements View.OnClickListener {
public class OpenAPSAMAFragment extends SubscriberFragment implements View.OnClickListener {
private static Logger log = LoggerFactory.getLogger(OpenAPSAMAFragment.class);
private static OpenAPSAMAPlugin openAPSAMAPlugin;
@ -81,18 +82,6 @@ public class OpenAPSAMAFragment extends Fragment implements View.OnClickListener
}
@Override
public void onPause() {
super.onPause();
MainApp.bus().unregister(this);
}
@Override
public void onResume() {
super.onResume();
MainApp.bus().register(this);
}
@Subscribe
public void onStatusEvent(final EventOpenAPSUpdateGui ev) {
updateGUI();
@ -103,7 +92,8 @@ public class OpenAPSAMAFragment extends Fragment implements View.OnClickListener
updateResultGUI(ev.text);
}
void updateGUI() {
@Override
protected void updateGUI() {
Activity activity = getActivity();
if (activity != null)
activity.runOnUiThread(new Runnable() {

View file

@ -18,11 +18,12 @@ import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateGui;
import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateResultGui;
import info.nightscout.utils.JSONFormatter;
public class OpenAPSMAFragment extends Fragment implements View.OnClickListener {
public class OpenAPSMAFragment extends SubscriberFragment implements View.OnClickListener {
private static Logger log = LoggerFactory.getLogger(OpenAPSMAFragment.class);
private static OpenAPSMAPlugin openAPSMAPlugin;
@ -75,18 +76,6 @@ public class OpenAPSMAFragment extends Fragment implements View.OnClickListener
}
@Override
public void onPause() {
super.onPause();
MainApp.bus().unregister(this);
}
@Override
public void onResume() {
super.onResume();
MainApp.bus().register(this);
}
@Subscribe
public void onStatusEvent(final EventOpenAPSUpdateGui ev) {
updateGUI();
@ -97,7 +86,8 @@ public class OpenAPSMAFragment extends Fragment implements View.OnClickListener
updateResultGUI(ev.text);
}
void updateGUI() {
@Override
protected void updateGUI() {
Activity activity = getActivity();
if (activity != null)
activity.runOnUiThread(new Runnable() {
@ -123,7 +113,7 @@ public class OpenAPSMAFragment extends Fragment implements View.OnClickListener
});
}
void updateResultGUI(final String text) {
private void updateResultGUI(final String text) {
Activity activity = getActivity();
if (activity != null)
activity.runOnUiThread(new Runnable() {

View file

@ -39,10 +39,11 @@ import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.plugins.Careportal.CareportalFragment;
import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog;
import info.nightscout.androidaps.plugins.Careportal.OptionsToShow;
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
import info.nightscout.utils.DecimalFormatter;
import info.nightscout.utils.SafeParse;
public class CircadianPercentageProfileFragment extends Fragment {
public class CircadianPercentageProfileFragment extends SubscriberFragment {
private static Logger log = LoggerFactory.getLogger(CircadianPercentageProfileFragment.class);
private static CircadianPercentageProfilePlugin circadianPercentageProfilePlugin = new CircadianPercentageProfilePlugin();
@ -309,16 +310,14 @@ public class CircadianPercentageProfileFragment extends Fragment {
percentageView.addTextChangedListener(textWatch);
timeshiftView.addTextChangedListener(textWatch);
updateGui();
updateGUI();
onStatusEvent(new EventInitializationChanged());
return layout;
}
public void updateGui() {
public void updateGUI() {
updateProfileInfo();
diaView.removeTextChangedListener(textWatch);
@ -484,15 +483,12 @@ public class CircadianPercentageProfileFragment extends Fragment {
}
basalEditDialog = null;
MainApp.bus().unregister(this);
fl.requestFocusFromTouch();
}
@Override
public void onResume() {
super.onResume();
updateGui();
MainApp.bus().register(this);
onStatusEvent(new EventInitializationChanged());
fl.requestFocusFromTouch();
}
@ -520,7 +516,7 @@ public class CircadianPercentageProfileFragment extends Fragment {
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
updateGui();
updateGUI();
}
});
}

View file

@ -27,10 +27,11 @@ import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.plugins.Careportal.CareportalFragment;
import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog;
import info.nightscout.androidaps.plugins.Careportal.OptionsToShow;
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
import info.nightscout.utils.SafeParse;
import info.nightscout.utils.TimeListEdit;
public class LocalProfileFragment extends Fragment {
public class LocalProfileFragment extends SubscriberFragment {
private static Logger log = LoggerFactory.getLogger(LocalProfileFragment.class);
private static LocalProfilePlugin localProfilePlugin = new LocalProfilePlugin();
@ -73,7 +74,7 @@ public class LocalProfileFragment extends Fragment {
layout.findViewById(R.id.localprofile_basal).setVisibility(View.GONE);
}
onStatusEvent(null);
updateGUI();
mgdlView.setChecked(localProfilePlugin.mgdl);
mmolView.setChecked(localProfilePlugin.mmol);
@ -130,26 +131,18 @@ public class LocalProfileFragment extends Fragment {
diaView.addTextChangedListener(textWatch);
onStatusEvent(null);
updateGUI();
return layout;
}
@Override
public void onPause() {
super.onPause();
MainApp.bus().unregister(this);
}
@Override
public void onResume() {
super.onResume();
MainApp.bus().register(this);
onStatusEvent(null);
}
@Subscribe
public void onStatusEvent(final EventInitializationChanged e) {
updateGUI();
}
@Override
protected void updateGUI() {
Activity activity = getActivity();
if (activity != null)
activity.runOnUiThread(new Runnable() {

View file

@ -13,10 +13,11 @@ import com.squareup.otto.Subscribe;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
import info.nightscout.androidaps.plugins.ProfileNS.events.EventNSProfileUpdateGUI;
import info.nightscout.utils.DecimalFormatter;
public class NSProfileFragment extends Fragment {
public class NSProfileFragment extends SubscriberFragment {
private static NSProfilePlugin nsProfilePlugin = new NSProfilePlugin();
public static NSProfilePlugin getPlugin() {
@ -50,18 +51,6 @@ public class NSProfileFragment extends Fragment {
return layout;
}
@Override
public void onPause() {
super.onPause();
MainApp.bus().unregister(this);
}
@Override
public void onResume() {
super.onResume();
MainApp.bus().register(this);
}
@Subscribe
public void onStatusEvent(final EventNSProfileUpdateGUI ev) {
Activity activity = getActivity();
@ -74,7 +63,8 @@ public class NSProfileFragment extends Fragment {
});
}
private void updateGUI() {
@Override
protected void updateGUI() {
if (MainApp.getConfigBuilder().getProfile() == null) {
noProfile.setVisibility(View.VISIBLE);
return;

View file

@ -25,9 +25,10 @@ import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.plugins.Careportal.CareportalFragment;
import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog;
import info.nightscout.androidaps.plugins.Careportal.OptionsToShow;
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
import info.nightscout.utils.SafeParse;
public class SimpleProfileFragment extends Fragment {
public class SimpleProfileFragment extends SubscriberFragment {
private static Logger log = LoggerFactory.getLogger(SimpleProfileFragment.class);
private static SimpleProfilePlugin simpleProfilePlugin = new SimpleProfilePlugin();
@ -66,7 +67,7 @@ public class SimpleProfileFragment extends Fragment {
layout.findViewById(R.id.simpleprofile_basalrate_label).setVisibility(View.GONE);
}
onStatusEvent(null);
updateGUI();
mgdlView.setChecked(simpleProfilePlugin.mgdl);
mmolView.setChecked(simpleProfilePlugin.mmol);
@ -138,26 +139,18 @@ public class SimpleProfileFragment extends Fragment {
targetlowView.addTextChangedListener(textWatch);
targethighView.addTextChangedListener(textWatch);
onStatusEvent(null);
updateGUI();
return layout;
}
@Override
public void onPause() {
super.onPause();
MainApp.bus().unregister(this);
}
@Override
public void onResume() {
super.onResume();
MainApp.bus().register(this);
onStatusEvent(null);
}
@Subscribe
public void onStatusEvent(final EventInitializationChanged e) {
updateGUI();
}
@Override
protected void updateGUI() {
Activity activity = getActivity();
if (activity != null)
activity.runOnUiThread(new Runnable() {

View file

@ -27,6 +27,7 @@ import info.nightscout.androidaps.R;
import info.nightscout.androidaps.events.EventExtendedBolusChange;
import info.nightscout.androidaps.events.EventPumpStatusChanged;
import info.nightscout.androidaps.events.EventTempBasalChange;
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
import info.nightscout.androidaps.plugins.PumpDanaR.Dialogs.ProfileViewDialog;
import info.nightscout.androidaps.plugins.PumpDanaR.activities.DanaRHistoryActivity;
import info.nightscout.androidaps.plugins.PumpDanaR.activities.DanaRStatsActivity;
@ -35,7 +36,7 @@ import info.nightscout.utils.DateUtil;
import info.nightscout.utils.DecimalFormatter;
import info.nightscout.utils.SetWarnColor;
public class DanaRFragment extends Fragment {
public class DanaRFragment extends SubscriberFragment {
private static Logger log = LoggerFactory.getLogger(DanaRFragment.class);
private static DanaRPlugin danaRPlugin;
@ -156,18 +157,6 @@ public class DanaRFragment extends Fragment {
return view;
}
@Override
public void onPause() {
super.onPause();
MainApp.bus().unregister(this);
}
@Override
public void onResume() {
super.onResume();
MainApp.bus().register(this);
}
@Subscribe
public void onStatusEvent(final EventPumpStatusChanged c) {
Activity activity = getActivity();
@ -204,7 +193,8 @@ public class DanaRFragment extends Fragment {
}
// GUI functions
private void updateGUI() {
@Override
protected void updateGUI() {
Activity activity = getActivity();
if (activity != null && basaBasalRateView != null)
activity.runOnUiThread(new Runnable() {

View file

@ -27,6 +27,7 @@ import info.nightscout.androidaps.R;
import info.nightscout.androidaps.events.EventExtendedBolusChange;
import info.nightscout.androidaps.events.EventPumpStatusChanged;
import info.nightscout.androidaps.events.EventTempBasalChange;
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
import info.nightscout.androidaps.plugins.PumpDanaR.Dialogs.ProfileViewDialog;
import info.nightscout.androidaps.plugins.PumpDanaR.activities.DanaRHistoryActivity;
@ -36,7 +37,7 @@ import info.nightscout.utils.DateUtil;
import info.nightscout.utils.DecimalFormatter;
import info.nightscout.utils.SetWarnColor;
public class DanaRKoreanFragment extends Fragment {
public class DanaRKoreanFragment extends SubscriberFragment {
private static Logger log = LoggerFactory.getLogger(DanaRKoreanFragment.class);
private static DanaRKoreanPlugin danaRKoreanPlugin = new DanaRKoreanPlugin();
@ -154,18 +155,6 @@ public class DanaRKoreanFragment extends Fragment {
return view;
}
@Override
public void onPause() {
super.onPause();
MainApp.bus().unregister(this);
}
@Override
public void onResume() {
super.onResume();
MainApp.bus().register(this);
}
@Subscribe
public void onStatusEvent(final EventPumpStatusChanged c) {
Activity activity = getActivity();
@ -202,7 +191,8 @@ public class DanaRKoreanFragment extends Fragment {
}
// GUI functions
private void updateGUI() {
@Override
protected void updateGUI() {
Activity activity = getActivity();
if (activity != null && basaBasalRateView != null)

View file

@ -27,6 +27,7 @@ import info.nightscout.androidaps.R;
import info.nightscout.androidaps.events.EventExtendedBolusChange;
import info.nightscout.androidaps.events.EventPumpStatusChanged;
import info.nightscout.androidaps.events.EventTempBasalChange;
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
import info.nightscout.androidaps.plugins.PumpDanaR.Dialogs.ProfileViewDialog;
import info.nightscout.androidaps.plugins.PumpDanaR.activities.DanaRHistoryActivity;
@ -36,7 +37,7 @@ import info.nightscout.utils.DateUtil;
import info.nightscout.utils.DecimalFormatter;
import info.nightscout.utils.SetWarnColor;
public class DanaRv2Fragment extends Fragment {
public class DanaRv2Fragment extends SubscriberFragment {
private static Logger log = LoggerFactory.getLogger(DanaRv2Fragment.class);
private static DanaRv2Plugin danaRPlugin;
@ -153,18 +154,6 @@ public class DanaRv2Fragment extends Fragment {
return view;
}
@Override
public void onPause() {
super.onPause();
MainApp.bus().unregister(this);
}
@Override
public void onResume() {
super.onResume();
MainApp.bus().register(this);
}
@Subscribe
public void onStatusEvent(final EventPumpStatusChanged c) {
Activity activity = getActivity();
@ -201,7 +190,8 @@ public class DanaRv2Fragment extends Fragment {
}
// GUI functions
private void updateGUI() {
@Override
protected void updateGUI() {
Activity activity = getActivity();
if (activity != null && basaBasalRateView != null)
activity.runOnUiThread(new Runnable() {

View file

@ -5,7 +5,6 @@ import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -16,13 +15,12 @@ import com.squareup.otto.Subscribe;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Date;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
import info.nightscout.androidaps.plugins.PumpVirtual.events.EventVirtualPumpUpdateGui;
public class VirtualPumpFragment extends Fragment {
public class VirtualPumpFragment extends SubscriberFragment {
private static Logger log = LoggerFactory.getLogger(VirtualPumpFragment.class);
TextView basaBasalRateView;
@ -63,24 +61,13 @@ public class VirtualPumpFragment extends Fragment {
return view;
}
@Override
public void onPause() {
super.onPause();
MainApp.bus().unregister(this);
}
@Override
public void onResume() {
super.onResume();
MainApp.bus().register(this);
}
@Subscribe
public void onStatusEvent(final EventVirtualPumpUpdateGui ev) {
updateGUI();
}
public void updateGUI() {
@Override
protected void updateGUI() {
Activity activity = getActivity();
if (activity != null && basaBasalRateView != null)
activity.runOnUiThread(new Runnable() {

View file

@ -20,13 +20,14 @@ import java.util.Comparator;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
import info.nightscout.androidaps.plugins.SmsCommunicator.events.EventSmsCommunicatorUpdateGui;
import info.nightscout.utils.DateUtil;
/**
* A simple {@link Fragment} subclass.
*/
public class SmsCommunicatorFragment extends Fragment {
public class SmsCommunicatorFragment extends SubscriberFragment {
private static Logger log = LoggerFactory.getLogger(SmsCommunicatorFragment.class);
private static SmsCommunicatorPlugin smsCommunicatorPlugin;
@ -56,25 +57,14 @@ public class SmsCommunicatorFragment extends Fragment {
return view;
}
@Override
public void onPause() {
super.onPause();
MainApp.bus().unregister(this);
}
@Override
public void onResume() {
super.onResume();
MainApp.bus().register(this);
}
@Subscribe
public void onStatusEvent(final EventSmsCommunicatorUpdateGui ev) {
updateGUI();
}
private void updateGUI() {
@Override
protected void updateGUI() {
Activity activity = getActivity();
if (activity != null)
activity.runOnUiThread(new Runnable() {

View file

@ -37,13 +37,14 @@ import info.nightscout.androidaps.db.Treatment;
import info.nightscout.androidaps.events.EventNewBG;
import info.nightscout.androidaps.events.EventTreatmentChange;
import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
import info.nightscout.utils.DateUtil;
import info.nightscout.utils.DecimalFormatter;
import info.nightscout.utils.NSUpload;
import info.nightscout.utils.SP;
public class TreatmentsBolusFragment extends Fragment implements View.OnClickListener {
public class TreatmentsBolusFragment extends SubscriberFragment implements View.OnClickListener {
private static Logger log = LoggerFactory.getLogger(TreatmentsBolusFragment.class);
RecyclerView recyclerView;
@ -205,19 +206,6 @@ public class TreatmentsBolusFragment extends Fragment implements View.OnClickLis
}
}
@Override
public void onPause() {
super.onPause();
MainApp.bus().unregister(this);
}
@Override
public void onResume() {
super.onResume();
MainApp.bus().register(this);
updateGUI();
}
@Subscribe
public void onStatusEvent(final EventTreatmentChange ev) {
updateGUI();
@ -228,7 +216,8 @@ public class TreatmentsBolusFragment extends Fragment implements View.OnClickLis
updateGUI();
}
public void updateGUI() {
@Override
protected void updateGUI() {
Activity activity = getActivity();
if (activity != null)
activity.runOnUiThread(new Runnable() {

View file

@ -30,13 +30,14 @@ import info.nightscout.androidaps.db.ExtendedBolus;
import info.nightscout.androidaps.db.Source;
import info.nightscout.androidaps.events.EventExtendedBolusChange;
import info.nightscout.androidaps.events.EventNewBG;
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
import info.nightscout.utils.DateUtil;
import info.nightscout.utils.DecimalFormatter;
import info.nightscout.utils.NSUpload;
import info.nightscout.androidaps.data.Intervals;
public class TreatmentsExtendedBolusesFragment extends Fragment {
public class TreatmentsExtendedBolusesFragment extends SubscriberFragment {
private static Logger log = LoggerFactory.getLogger(TreatmentsExtendedBolusesFragment.class);
RecyclerView recyclerView;
@ -181,18 +182,6 @@ public class TreatmentsExtendedBolusesFragment extends Fragment {
return view;
}
@Override
public void onPause() {
super.onPause();
MainApp.bus().unregister(this);
}
@Override
public void onResume() {
super.onResume();
MainApp.bus().register(this);
}
@Subscribe
public void onStatusEvent(final EventExtendedBolusChange ev) {
updateGUI();
@ -203,7 +192,8 @@ public class TreatmentsExtendedBolusesFragment extends Fragment {
updateGUI();
}
public void updateGUI() {
@Override
protected void updateGUI() {
Activity activity = getActivity();
if (activity != null && recyclerView != null)
activity.runOnUiThread(new Runnable() {

View file

@ -30,6 +30,7 @@ import info.nightscout.androidaps.db.Source;
import info.nightscout.androidaps.db.TempTarget;
import info.nightscout.androidaps.events.EventProfileSwitchChange;
import info.nightscout.androidaps.events.EventTempTargetChange;
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
import info.nightscout.utils.DateUtil;
import info.nightscout.utils.DecimalFormatter;
import info.nightscout.utils.NSUpload;
@ -40,7 +41,7 @@ import info.nightscout.utils.SP;
* Created by mike on 13/01/17.
*/
public class TreatmentsProfileSwitchFragment extends Fragment implements View.OnClickListener {
public class TreatmentsProfileSwitchFragment extends SubscriberFragment implements View.OnClickListener {
RecyclerView recyclerView;
LinearLayoutManager llm;
@ -180,24 +181,13 @@ public class TreatmentsProfileSwitchFragment extends Fragment implements View.On
}
}
@Override
public void onPause() {
super.onPause();
MainApp.bus().unregister(this);
}
@Override
public void onResume() {
super.onResume();
MainApp.bus().register(this);
}
@Subscribe
public void onStatusEvent(final EventProfileSwitchChange ev) {
updateGUI();
}
void updateGUI() {
@Override
protected void updateGUI() {
Activity activity = getActivity();
if (activity != null)
activity.runOnUiThread(new Runnable() {

View file

@ -26,6 +26,7 @@ import info.nightscout.androidaps.Services.Intents;
import info.nightscout.androidaps.db.Source;
import info.nightscout.androidaps.db.TempTarget;
import info.nightscout.androidaps.events.EventTempTargetChange;
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
import info.nightscout.utils.DateUtil;
import info.nightscout.utils.DecimalFormatter;
import info.nightscout.utils.NSUpload;
@ -36,7 +37,7 @@ import info.nightscout.utils.SP;
* Created by mike on 13/01/17.
*/
public class TreatmentsTempTargetFragment extends Fragment implements View.OnClickListener {
public class TreatmentsTempTargetFragment extends SubscriberFragment implements View.OnClickListener {
RecyclerView recyclerView;
LinearLayoutManager llm;
@ -210,24 +211,13 @@ public class TreatmentsTempTargetFragment extends Fragment implements View.OnCli
}
@Override
public void onPause() {
super.onPause();
MainApp.bus().unregister(this);
}
@Override
public void onResume() {
super.onResume();
MainApp.bus().register(this);
}
@Subscribe
public void onStatusEvent(final EventTempTargetChange ev) {
updateGUI();
}
void updateGUI() {
@Override
protected void updateGUI() {
Activity activity = getActivity();
if (activity != null)
activity.runOnUiThread(new Runnable() {

View file

@ -30,13 +30,14 @@ import info.nightscout.androidaps.db.Source;
import info.nightscout.androidaps.db.TemporaryBasal;
import info.nightscout.androidaps.events.EventNewBG;
import info.nightscout.androidaps.events.EventTempBasalChange;
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
import info.nightscout.utils.DateUtil;
import info.nightscout.utils.DecimalFormatter;
import info.nightscout.utils.NSUpload;
import info.nightscout.androidaps.data.Intervals;
public class TreatmentsTemporaryBasalsFragment extends Fragment {
public class TreatmentsTemporaryBasalsFragment extends SubscriberFragment {
private static Logger log = LoggerFactory.getLogger(TreatmentsTemporaryBasalsFragment.class);
RecyclerView recyclerView;
@ -200,18 +201,6 @@ public class TreatmentsTemporaryBasalsFragment extends Fragment {
return view;
}
@Override
public void onPause() {
super.onPause();
MainApp.bus().unregister(this);
}
@Override
public void onResume() {
super.onResume();
MainApp.bus().register(this);
}
@Subscribe
public void onStatusEvent(final EventTempBasalChange ev) {
updateGUI();
@ -222,7 +211,8 @@ public class TreatmentsTemporaryBasalsFragment extends Fragment {
updateGUI();
}
public void updateGUI() {
@Override
protected void updateGUI() {
Activity activity = getActivity();
if (activity != null)
activity.runOnUiThread(new Runnable() {