Extract SubscriberFragment base class.

This commit is contained in:
Johannes Mockenhaupt 2017-07-18 12:56:56 +02:00
parent 7c6bdc0b31
commit 435ec55580
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1
20 changed files with 109 additions and 293 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();
@ -86,19 +87,6 @@ public class ActionsFragment 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);
updateGUI();
}
@Subscribe
public void onStatusEvent(final EventInitializationChanged ev) {
updateGUI();
@ -119,7 +107,8 @@ public class ActionsFragment extends Fragment implements View.OnClickListener {
updateGUI();
}
private void updateGUI() {
@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,25 +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);
updateGUI();
}
@Subscribe
public void onStatusEvent(final EventCareportalEventChange c) {
updateGUI();
}
private 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

@ -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,19 +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);
updateGUI();
}
@Override
public void onClick(View view) {
switch (view.getId()) {
@ -111,7 +98,8 @@ public class LoopFragment extends Fragment implements View.OnClickListener {
}
private 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,19 +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);
updateGUI();
}
@Subscribe
public void onStatusEvent(final EventOpenAPSUpdateGui ev) {
updateGUI();
@ -104,7 +92,8 @@ public class OpenAPSAMAFragment extends Fragment implements View.OnClickListener
updateResultGUI(ev.text);
}
private 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,19 +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);
updateGUI();
}
@Subscribe
public void onStatusEvent(final EventOpenAPSUpdateGui ev) {
updateGUI();
@ -98,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() {
@ -124,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

@ -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,19 +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);
updateGUI();
}
@Subscribe
public void onStatusEvent(final EventNSProfileUpdateGUI ev) {
Activity activity = getActivity();
@ -75,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,19 +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);
updateGUI();
}
@Subscribe
public void onStatusEvent(final EventPumpStatusChanged c) {
Activity activity = getActivity();
@ -205,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,19 +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);
updateGUI();
}
@Subscribe
public void onStatusEvent(final EventPumpStatusChanged c) {
Activity activity = getActivity();
@ -203,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,19 +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);
updateGUI();
}
@Subscribe
public void onStatusEvent(final EventPumpStatusChanged c) {
Activity activity = getActivity();
@ -202,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,25 +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);
updateGUI();
}
@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,26 +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);
updateGUI();
}
@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

@ -32,13 +32,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.OverlappingIntervals;
public class TreatmentsExtendedBolusesFragment extends Fragment {
public class TreatmentsExtendedBolusesFragment extends SubscriberFragment {
private static Logger log = LoggerFactory.getLogger(TreatmentsExtendedBolusesFragment.class);
RecyclerView recyclerView;
@ -183,19 +184,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);
updateGUI();
}
@Subscribe
public void onStatusEvent(final EventExtendedBolusChange ev) {
updateGUI();
@ -206,7 +194,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,25 +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);
updateGUI();
}
@Subscribe
public void onStatusEvent(final EventProfileSwitchChange ev) {
updateGUI();
}
private void updateGUI() {
@Override
protected void updateGUI() {
Activity activity = getActivity();
if (activity != null)
activity.runOnUiThread(new Runnable() {

View file

@ -26,7 +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.data.Profile;
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
import info.nightscout.utils.DateUtil;
import info.nightscout.utils.DecimalFormatter;
import info.nightscout.utils.NSUpload;
@ -37,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;
@ -201,25 +201,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);
updateGUI();
}
@Subscribe
public void onStatusEvent(final EventTempTargetChange ev) {
updateGUI();
}
private void updateGUI() {
@Override
protected void updateGUI() {
Activity activity = getActivity();
if (activity != null)
activity.runOnUiThread(new Runnable() {

View file

@ -32,13 +32,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.OverlappingIntervals;
public class TreatmentsTemporaryBasalsFragment extends Fragment {
public class TreatmentsTemporaryBasalsFragment extends SubscriberFragment {
private static Logger log = LoggerFactory.getLogger(TreatmentsTemporaryBasalsFragment.class);
RecyclerView recyclerView;
@ -202,19 +203,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);
updateGUI();
}
@Subscribe
public void onStatusEvent(final EventTempBasalChange ev) {
updateGUI();
@ -225,7 +213,8 @@ public class TreatmentsTemporaryBasalsFragment extends Fragment {
updateGUI();
}
public void updateGUI() {
@Override
protected void updateGUI() {
Activity activity = getActivity();
if (activity != null)
activity.runOnUiThread(new Runnable() {