Get thresholds from NS
This commit is contained in:
parent
79ba8b9c3b
commit
af0140f6b9
1 changed files with 166 additions and 100 deletions
|
@ -3,9 +3,7 @@ package info.nightscout.androidaps.plugins.Careportal;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.Fragment;
|
|
||||||
import android.support.v4.app.FragmentManager;
|
import android.support.v4.app.FragmentManager;
|
||||||
import android.text.Layout;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
@ -14,22 +12,27 @@ import android.widget.TextView;
|
||||||
|
|
||||||
import com.squareup.otto.Subscribe;
|
import com.squareup.otto.Subscribe;
|
||||||
|
|
||||||
|
import org.json.JSONException;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import info.nightscout.androidaps.BuildConfig;
|
import info.nightscout.androidaps.BuildConfig;
|
||||||
|
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.Profile;
|
|
||||||
import info.nightscout.androidaps.data.ProfileStore;
|
import info.nightscout.androidaps.data.ProfileStore;
|
||||||
import info.nightscout.androidaps.db.CareportalEvent;
|
import info.nightscout.androidaps.db.CareportalEvent;
|
||||||
import info.nightscout.androidaps.events.EventCareportalEventChange;
|
import info.nightscout.androidaps.events.EventCareportalEventChange;
|
||||||
import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog;
|
import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog;
|
||||||
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
|
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSSettingsStatus;
|
||||||
import info.nightscout.androidaps.plugins.Overview.OverviewFragment;
|
import info.nightscout.androidaps.plugins.Overview.OverviewFragment;
|
||||||
|
import info.nightscout.utils.FabricPrivacy;
|
||||||
|
|
||||||
public class CareportalFragment extends SubscriberFragment implements View.OnClickListener {
|
public class CareportalFragment extends SubscriberFragment implements View.OnClickListener {
|
||||||
|
private static Logger log = LoggerFactory.getLogger(CareportalFragment.class);
|
||||||
static CareportalPlugin careportalPlugin;
|
|
||||||
|
|
||||||
TextView iage;
|
TextView iage;
|
||||||
TextView cage;
|
TextView cage;
|
||||||
TextView sage;
|
TextView sage;
|
||||||
|
@ -39,38 +42,33 @@ public class CareportalFragment extends SubscriberFragment implements View.OnCli
|
||||||
LinearLayout butonsLayout;
|
LinearLayout butonsLayout;
|
||||||
View noProfileView;
|
View noProfileView;
|
||||||
|
|
||||||
static public CareportalPlugin getPlugin() {
|
// date,bg,insulin,carbs,prebolus,duration,percent,absolute,profile,split,temptarget
|
||||||
if (careportalPlugin == null) {
|
public static final OptionsToShow BGCHECK = new OptionsToShow(R.id.careportal_bgcheck, R.string.careportal_bgcheck).date().bg();
|
||||||
careportalPlugin = new CareportalPlugin();
|
public static final OptionsToShow SNACKBOLUS = new OptionsToShow(R.id.careportal_snackbolus, R.string.careportal_snackbolus).date().bg().insulin().carbs().prebolus();
|
||||||
}
|
public static final OptionsToShow MEALBOLUS = new OptionsToShow(R.id.careportal_mealbolus, R.string.careportal_mealbolus).date().bg().insulin().carbs().prebolus();
|
||||||
return careportalPlugin;
|
public static final OptionsToShow CORRECTIONBOLUS = new OptionsToShow(R.id.careportal_correctionbolus, R.string.careportal_correctionbolus).date().bg().insulin().carbs().prebolus();
|
||||||
}
|
public static final OptionsToShow CARBCORRECTION = new OptionsToShow(R.id.careportal_carbscorrection, R.string.careportal_carbscorrection).date().bg().carbs();
|
||||||
|
public static final OptionsToShow COMBOBOLUS = new OptionsToShow(R.id.careportal_combobolus, R.string.careportal_combobolus).date().bg().insulin().carbs().prebolus().duration().split();
|
||||||
// bg,insulin,carbs,prebolus,duration,percent,absolute,profile,split,temptarget
|
public static final OptionsToShow ANNOUNCEMENT = new OptionsToShow(R.id.careportal_announcement, R.string.careportal_announcement).date().bg();
|
||||||
public static final OptionsToShow bgcheck = new OptionsToShow(R.id.careportal_bgcheck, R.string.careportal_bgcheck, true, true, true, false, false, false, false, false, false, false);
|
public static final OptionsToShow NOTE = new OptionsToShow(R.id.careportal_note, R.string.careportal_note).date().bg().duration();
|
||||||
public static final OptionsToShow snackbolus = new OptionsToShow(R.id.careportal_snackbolus, R.string.careportal_snackbolus, true, true, true, true, false, false, false, false, false, false);
|
public static final OptionsToShow QUESTION = new OptionsToShow(R.id.careportal_question, R.string.careportal_question).date().bg();
|
||||||
public static final OptionsToShow mealbolus = new OptionsToShow(R.id.careportal_mealbolus, R.string.careportal_mealbolus, true, true, true, true, false, false, false, false, false, false);
|
public static final OptionsToShow EXERCISE = new OptionsToShow(R.id.careportal_exercise, R.string.careportal_exercise).date().duration();
|
||||||
public static final OptionsToShow correctionbolus = new OptionsToShow(R.id.careportal_correctionbolus, R.string.careportal_correctionbolus, true, true, true, true, false, false, false, false, false, false);
|
public static final OptionsToShow SITECHANGE = new OptionsToShow(R.id.careportal_pumpsitechange, R.string.careportal_pumpsitechange).date().bg();
|
||||||
public static final OptionsToShow carbcorrection = new OptionsToShow(R.id.careportal_carbscorrection, R.string.careportal_carbscorrection, true, false, true, false, false, false, false, false, false, false);
|
public static final OptionsToShow SENSORSTART = new OptionsToShow(R.id.careportal_cgmsensorstart, R.string.careportal_cgmsensorstart).date().bg();
|
||||||
public static final OptionsToShow combobolus = new OptionsToShow(R.id.careportal_combobolus, R.string.careportal_combobolus, true, true, true, true, true, false, false, false, true, false);
|
public static final OptionsToShow SENSORCHANGE = new OptionsToShow(R.id.careportal_cgmsensorinsert, R.string.careportal_cgmsensorinsert).date().bg();
|
||||||
public static final OptionsToShow announcement = new OptionsToShow(R.id.careportal_announcement, R.string.careportal_announcement, true, false, false, false, false, false, false, false, false, false);
|
public static final OptionsToShow INSULINCHANGE = new OptionsToShow(R.id.careportal_insulincartridgechange, R.string.careportal_insulincartridgechange).date().bg();
|
||||||
public static final OptionsToShow note = new OptionsToShow(R.id.careportal_note, R.string.careportal_note, true, false, false, false, true, false, false, false, false, false);
|
public static final OptionsToShow PUMPBATTERYCHANGE = new OptionsToShow(R.id.careportal_pumpbatterychange, R.string.careportal_pumpbatterychange).date().bg();
|
||||||
public static final OptionsToShow question = new OptionsToShow(R.id.careportal_question, R.string.careportal_question, true, false, false, false, false, false, false, false, false, false);
|
public static final OptionsToShow TEMPBASALSTART = new OptionsToShow(R.id.careportal_tempbasalstart, R.string.careportal_tempbasalstart).date().bg().duration().percent().absolute();
|
||||||
public static final OptionsToShow exercise = new OptionsToShow(R.id.careportal_exercise, R.string.careportal_exercise, false, false, false, false, true, false, false, false, false, false);
|
public static final OptionsToShow TEMPBASALEND = new OptionsToShow(R.id.careportal_tempbasalend, R.string.careportal_tempbasalend).date().bg();
|
||||||
public static final OptionsToShow sitechange = new OptionsToShow(R.id.careportal_pumpsitechange, R.string.careportal_pumpsitechange, true, true, false, false, false, false, false, false, false, false);
|
public static final OptionsToShow PROFILESWITCH = new OptionsToShow(R.id.careportal_profileswitch, R.string.careportal_profileswitch).date().duration().profile();
|
||||||
public static final OptionsToShow sensorstart = new OptionsToShow(R.id.careportal_cgmsensorstart, R.string.careportal_cgmsensorstart, true, false, false, false, false, false, false, false, false, false);
|
public static final OptionsToShow PROFILESWITCHDIRECT = new OptionsToShow(R.id.careportal_profileswitch, R.string.careportal_profileswitch).duration().profile();
|
||||||
public static final OptionsToShow sensorchange = new OptionsToShow(R.id.careportal_cgmsensorinsert, R.string.careportal_cgmsensorinsert, true, false, false, false, false, false, false, false, false, false);
|
public static final OptionsToShow OPENAPSOFFLINE = new OptionsToShow(R.id.careportal_openapsoffline, R.string.careportal_openapsoffline).date().duration();
|
||||||
public static final OptionsToShow insulinchange = new OptionsToShow(R.id.careportal_insulincartridgechange, R.string.careportal_insulincartridgechange, true, false, false, false, false, false, false, false, false, false);
|
public static final OptionsToShow TEMPTARGET = new OptionsToShow(R.id.careportal_temporarytarget, R.string.careportal_temporarytarget).date().duration().tempTarget();
|
||||||
public static final OptionsToShow pumpbatterychange = new OptionsToShow(R.id.careportal_pumpbatterychange, R.string.careportal_pumpbatterychange, true, false, false, false, false, false, false, false, false, false);
|
|
||||||
public static final OptionsToShow tempbasalstart = new OptionsToShow(R.id.careportal_tempbasalstart, R.string.careportal_tempbasalstart, true, false, false, false, true, true, true, false, false, false);
|
|
||||||
public static final OptionsToShow tempbasalend = new OptionsToShow(R.id.careportal_tempbasalend, R.string.careportal_tempbasalend, true, false, false, false, false, false, false, false, false, false);
|
|
||||||
public static final OptionsToShow profileswitch = new OptionsToShow(R.id.careportal_profileswitch, R.string.careportal_profileswitch, true, false, false, false, true, false, false, true, false, false);
|
|
||||||
public static final OptionsToShow openapsoffline = new OptionsToShow(R.id.careportal_openapsoffline, R.string.careportal_openapsoffline, false, false, false, false, true, false, false, false, false, false);
|
|
||||||
public static final OptionsToShow temptarget = new OptionsToShow(R.id.careportal_temporarytarget, R.string.careportal_temporarytarget, false, false, false, false, true, false, false, false, false, true);
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
|
try {
|
||||||
View view = inflater.inflate(R.layout.careportal_fragment, container, false);
|
View view = inflater.inflate(R.layout.careportal_fragment, container, false);
|
||||||
|
|
||||||
view.findViewById(R.id.careportal_bgcheck).setOnClickListener(this);
|
view.findViewById(R.id.careportal_bgcheck).setOnClickListener(this);
|
||||||
|
@ -99,12 +97,12 @@ public class CareportalFragment extends SubscriberFragment implements View.OnCli
|
||||||
sage = (TextView) view.findViewById(R.id.careportal_sensorage);
|
sage = (TextView) view.findViewById(R.id.careportal_sensorage);
|
||||||
pbage = (TextView) view.findViewById(R.id.careportal_pbage);
|
pbage = (TextView) view.findViewById(R.id.careportal_pbage);
|
||||||
|
|
||||||
statsLayout = (View) view.findViewById(R.id.careportal_stats);
|
statsLayout = view.findViewById(R.id.careportal_stats);
|
||||||
|
|
||||||
noProfileView = (View) view.findViewById(R.id.profileview_noprofile);
|
noProfileView = view.findViewById(R.id.profileview_noprofile);
|
||||||
butonsLayout = (LinearLayout) view.findViewById(R.id.careportal_buttons);
|
butonsLayout = (LinearLayout) view.findViewById(R.id.careportal_buttons);
|
||||||
|
|
||||||
ProfileStore profileStore = ConfigBuilderPlugin.getActiveProfileInterface().getProfile();
|
ProfileStore profileStore = MainApp.getConfigBuilder().getActiveProfileInterface().getProfile();
|
||||||
if (profileStore == null) {
|
if (profileStore == null) {
|
||||||
noProfileView.setVisibility(View.VISIBLE);
|
noProfileView.setVisibility(View.VISIBLE);
|
||||||
butonsLayout.setVisibility(View.GONE);
|
butonsLayout.setVisibility(View.GONE);
|
||||||
|
@ -113,11 +111,16 @@ public class CareportalFragment extends SubscriberFragment implements View.OnCli
|
||||||
butonsLayout.setVisibility(View.VISIBLE);
|
butonsLayout.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (BuildConfig.NSCLIENTOLNY)
|
if (Config.NSCLIENT || Config.G5UPLOADER)
|
||||||
statsLayout.setVisibility(View.GONE); // visible on overview
|
statsLayout.setVisibility(View.GONE); // visible on overview
|
||||||
|
|
||||||
updateGUI();
|
updateGUI();
|
||||||
return view;
|
return view;
|
||||||
|
} catch (Exception e) {
|
||||||
|
FabricPrivacy.logException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -129,66 +132,66 @@ public class CareportalFragment extends SubscriberFragment implements View.OnCli
|
||||||
NewNSTreatmentDialog newDialog = new NewNSTreatmentDialog();
|
NewNSTreatmentDialog newDialog = new NewNSTreatmentDialog();
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case R.id.careportal_bgcheck:
|
case R.id.careportal_bgcheck:
|
||||||
newDialog.setOptions(bgcheck, R.string.careportal_bgcheck);
|
newDialog.setOptions(BGCHECK, R.string.careportal_bgcheck);
|
||||||
break;
|
break;
|
||||||
case R.id.careportal_announcement:
|
case R.id.careportal_announcement:
|
||||||
newDialog.setOptions(announcement, R.string.careportal_announcement);
|
newDialog.setOptions(ANNOUNCEMENT, R.string.careportal_announcement);
|
||||||
break;
|
break;
|
||||||
case R.id.careportal_cgmsensorinsert:
|
case R.id.careportal_cgmsensorinsert:
|
||||||
newDialog.setOptions(sensorchange, R.string.careportal_cgmsensorinsert);
|
newDialog.setOptions(SENSORCHANGE, R.string.careportal_cgmsensorinsert);
|
||||||
break;
|
break;
|
||||||
case R.id.careportal_cgmsensorstart:
|
case R.id.careportal_cgmsensorstart:
|
||||||
newDialog.setOptions(sensorstart, R.string.careportal_cgmsensorstart);
|
newDialog.setOptions(SENSORSTART, R.string.careportal_cgmsensorstart);
|
||||||
break;
|
break;
|
||||||
case R.id.careportal_combobolus:
|
case R.id.careportal_combobolus:
|
||||||
newDialog.setOptions(combobolus, R.string.careportal_combobolus);
|
newDialog.setOptions(COMBOBOLUS, R.string.careportal_combobolus);
|
||||||
break;
|
break;
|
||||||
case R.id.careportal_correctionbolus:
|
case R.id.careportal_correctionbolus:
|
||||||
newDialog.setOptions(correctionbolus, R.string.careportal_correctionbolus);
|
newDialog.setOptions(CORRECTIONBOLUS, R.string.careportal_correctionbolus);
|
||||||
break;
|
break;
|
||||||
case R.id.careportal_carbscorrection:
|
case R.id.careportal_carbscorrection:
|
||||||
newDialog.setOptions(carbcorrection, R.string.careportal_carbscorrection);
|
newDialog.setOptions(CARBCORRECTION, R.string.careportal_carbscorrection);
|
||||||
break;
|
break;
|
||||||
case R.id.careportal_exercise:
|
case R.id.careportal_exercise:
|
||||||
newDialog.setOptions(exercise, R.string.careportal_exercise);
|
newDialog.setOptions(EXERCISE, R.string.careportal_exercise);
|
||||||
break;
|
break;
|
||||||
case R.id.careportal_insulincartridgechange:
|
case R.id.careportal_insulincartridgechange:
|
||||||
newDialog.setOptions(insulinchange, R.string.careportal_insulincartridgechange);
|
newDialog.setOptions(INSULINCHANGE, R.string.careportal_insulincartridgechange);
|
||||||
break;
|
break;
|
||||||
case R.id.careportal_pumpbatterychange:
|
case R.id.careportal_pumpbatterychange:
|
||||||
newDialog.setOptions(pumpbatterychange, R.string.careportal_pumpbatterychange);
|
newDialog.setOptions(PUMPBATTERYCHANGE, R.string.careportal_pumpbatterychange);
|
||||||
break;
|
break;
|
||||||
case R.id.careportal_mealbolus:
|
case R.id.careportal_mealbolus:
|
||||||
newDialog.setOptions(mealbolus, R.string.careportal_mealbolus);
|
newDialog.setOptions(MEALBOLUS, R.string.careportal_mealbolus);
|
||||||
break;
|
break;
|
||||||
case R.id.careportal_note:
|
case R.id.careportal_note:
|
||||||
newDialog.setOptions(note, R.string.careportal_note);
|
newDialog.setOptions(NOTE, R.string.careportal_note);
|
||||||
break;
|
break;
|
||||||
case R.id.careportal_profileswitch:
|
case R.id.careportal_profileswitch:
|
||||||
profileswitch.executeProfileSwitch = false;
|
PROFILESWITCH.executeProfileSwitch = false;
|
||||||
newDialog.setOptions(profileswitch, R.string.careportal_profileswitch);
|
newDialog.setOptions(PROFILESWITCH, R.string.careportal_profileswitch);
|
||||||
break;
|
break;
|
||||||
case R.id.careportal_pumpsitechange:
|
case R.id.careportal_pumpsitechange:
|
||||||
newDialog.setOptions(sitechange, R.string.careportal_pumpsitechange);
|
newDialog.setOptions(SITECHANGE, R.string.careportal_pumpsitechange);
|
||||||
break;
|
break;
|
||||||
case R.id.careportal_question:
|
case R.id.careportal_question:
|
||||||
newDialog.setOptions(question, R.string.careportal_question);
|
newDialog.setOptions(QUESTION, R.string.careportal_question);
|
||||||
break;
|
break;
|
||||||
case R.id.careportal_snackbolus:
|
case R.id.careportal_snackbolus:
|
||||||
newDialog.setOptions(snackbolus, R.string.careportal_snackbolus);
|
newDialog.setOptions(SNACKBOLUS, R.string.careportal_snackbolus);
|
||||||
break;
|
break;
|
||||||
case R.id.careportal_tempbasalstart:
|
case R.id.careportal_tempbasalstart:
|
||||||
newDialog.setOptions(tempbasalstart, R.string.careportal_tempbasalstart);
|
newDialog.setOptions(TEMPBASALSTART, R.string.careportal_tempbasalstart);
|
||||||
break;
|
break;
|
||||||
case R.id.careportal_tempbasalend:
|
case R.id.careportal_tempbasalend:
|
||||||
newDialog.setOptions(tempbasalend, R.string.careportal_tempbasalend);
|
newDialog.setOptions(TEMPBASALEND, R.string.careportal_tempbasalend);
|
||||||
break;
|
break;
|
||||||
case R.id.careportal_openapsoffline:
|
case R.id.careportal_openapsoffline:
|
||||||
newDialog.setOptions(openapsoffline, R.string.careportal_openapsoffline);
|
newDialog.setOptions(OPENAPSOFFLINE, R.string.careportal_openapsoffline);
|
||||||
break;
|
break;
|
||||||
case R.id.careportal_temporarytarget:
|
case R.id.careportal_temporarytarget:
|
||||||
temptarget.executeTempTarget = false;
|
TEMPTARGET.executeTempTarget = false;
|
||||||
newDialog.setOptions(temptarget, R.string.careportal_temporarytarget);
|
newDialog.setOptions(TEMPTARGET, R.string.careportal_temporarytarget);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
newDialog = null;
|
newDialog = null;
|
||||||
|
@ -215,22 +218,84 @@ public class CareportalFragment extends SubscriberFragment implements View.OnCli
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
CareportalEvent careportalEvent;
|
CareportalEvent careportalEvent;
|
||||||
|
NSSettingsStatus nsSettings = new NSSettingsStatus().getInstance();
|
||||||
|
JSONObject extendedSettings = nsSettings.getExtendedSettings();
|
||||||
|
// Thresholds in NS are in hours
|
||||||
|
double iageThreshold = 7*24;
|
||||||
|
double cageThreshold = 3*24;
|
||||||
|
double sageThreshold = 7*24;
|
||||||
|
double pbageThreshold = 15*24;
|
||||||
|
log.debug("NSExtendedSettings are "+extendedSettings.toString());
|
||||||
|
// try {
|
||||||
|
JSONObject iageSettings = extendedSettings.optJSONObject("iage");
|
||||||
|
if(iageSettings != null)
|
||||||
|
iageThreshold = iageSettings.optDouble("urgent", 7*24);
|
||||||
|
JSONObject cageSettings = extendedSettings.optJSONObject("cage");
|
||||||
|
if(cageSettings != null)
|
||||||
|
cageThreshold = cageSettings.optDouble("urgent", 3*24);
|
||||||
|
log.debug("cageThreshold is "+cageThreshold);
|
||||||
|
JSONObject sageSettings = extendedSettings.optJSONObject("sage");
|
||||||
|
if(sageSettings != null)
|
||||||
|
sageThreshold = sageSettings.optDouble("urgent", 7*24);
|
||||||
|
// } catch (JSONException e) {
|
||||||
|
// log.error("Unhandled exception", e);
|
||||||
|
// }
|
||||||
String notavailable = OverviewFragment.shorttextmode ? "-" : MainApp.sResources.getString(R.string.notavailable);
|
String notavailable = OverviewFragment.shorttextmode ? "-" : MainApp.sResources.getString(R.string.notavailable);
|
||||||
if (sage != null) {
|
if (sage != null) {
|
||||||
careportalEvent = MainApp.getDbHelper().getLastCareportalEvent(CareportalEvent.SENSORCHANGE);
|
careportalEvent = MainApp.getDbHelper().getLastCareportalEvent(CareportalEvent.SENSORCHANGE);
|
||||||
sage.setText(careportalEvent != null ? careportalEvent.age() : notavailable);
|
if(careportalEvent != null) {
|
||||||
|
if(careportalEvent.isOlderThan( sageThreshold/24)){
|
||||||
|
sage.setTextColor(MainApp.sResources.getColor(R.color.low));
|
||||||
|
sage.setText(careportalEvent.age());
|
||||||
|
} else {
|
||||||
|
sage.setText(careportalEvent.age());
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
sage.setText(notavailable);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (iage != null) {
|
if (iage != null) {
|
||||||
careportalEvent = MainApp.getDbHelper().getLastCareportalEvent(CareportalEvent.INSULINCHANGE);
|
careportalEvent = MainApp.getDbHelper().getLastCareportalEvent(CareportalEvent.INSULINCHANGE);
|
||||||
iage.setText(careportalEvent != null ? careportalEvent.age() : notavailable);
|
if(careportalEvent != null) {
|
||||||
|
if(careportalEvent.isOlderThan(iageThreshold/24)){
|
||||||
|
iage.setTextColor(MainApp.sResources.getColor(R.color.low));
|
||||||
|
iage.setText(careportalEvent.age());
|
||||||
|
} else {
|
||||||
|
iage.setText(careportalEvent.age());
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
iage.setText(notavailable);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (cage != null) {
|
if (cage != null) {
|
||||||
careportalEvent = MainApp.getDbHelper().getLastCareportalEvent(CareportalEvent.SITECHANGE);
|
careportalEvent = MainApp.getDbHelper().getLastCareportalEvent(CareportalEvent.SITECHANGE);
|
||||||
cage.setText(careportalEvent != null ? careportalEvent.age() : notavailable);
|
if (careportalEvent != null) {
|
||||||
|
if(careportalEvent.isOlderThan(cageThreshold/24)){
|
||||||
|
cage.setTextColor(MainApp.sResources.getColor(R.color.low));
|
||||||
|
cage.setText(careportalEvent.age());
|
||||||
|
} else {
|
||||||
|
cage.setText(careportalEvent.age());
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
cage.setText(notavailable);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (pbage != null) {
|
if (pbage != null) {
|
||||||
careportalEvent = MainApp.getDbHelper().getLastCareportalEvent(CareportalEvent.PUMPBATTERYCHANGE);
|
careportalEvent = MainApp.getDbHelper().getLastCareportalEvent(CareportalEvent.PUMPBATTERYCHANGE);
|
||||||
pbage.setText(careportalEvent != null ? careportalEvent.age() : notavailable);
|
if(careportalEvent != null) {
|
||||||
|
if(careportalEvent.isOlderThan(pbageThreshold/24)){
|
||||||
|
pbage.setTextColor(MainApp.sResources.getColor(R.color.low));
|
||||||
|
pbage.setText(careportalEvent.age());
|
||||||
|
} else {
|
||||||
|
pbage.setText(careportalEvent.age());
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
pbage.setText(notavailable);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -239,3 +304,4 @@ public class CareportalFragment extends SubscriberFragment implements View.OnCli
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue