run rendering calculations on background
This commit is contained in:
parent
88b9caa357
commit
e0a6db22a2
7 changed files with 787 additions and 667 deletions
|
@ -212,9 +212,6 @@ public class ActionsFragment extends Fragment implements View.OnClickListener {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
DanaRv2Plugin danaRv2Plugin = (DanaRv2Plugin) MainApp.getSpecificPlugin(DanaRv2Plugin.class);
|
DanaRv2Plugin danaRv2Plugin = (DanaRv2Plugin) MainApp.getSpecificPlugin(DanaRv2Plugin.class);
|
||||||
if (MainApp.getConfigBuilder().isTempBasalInProgress()) {
|
|
||||||
danaRv2Plugin.cancelTempBasal();
|
|
||||||
}
|
|
||||||
danaRv2Plugin.setHighTempBasalPercent(50);
|
danaRv2Plugin.setHighTempBasalPercent(50);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -224,9 +221,6 @@ public class ActionsFragment extends Fragment implements View.OnClickListener {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
DanaRv2Plugin danaRv2Plugin = (DanaRv2Plugin) MainApp.getSpecificPlugin(DanaRv2Plugin.class);
|
DanaRv2Plugin danaRv2Plugin = (DanaRv2Plugin) MainApp.getSpecificPlugin(DanaRv2Plugin.class);
|
||||||
if (MainApp.getConfigBuilder().isTempBasalInProgress()) {
|
|
||||||
danaRv2Plugin.cancelTempBasal();
|
|
||||||
}
|
|
||||||
danaRv2Plugin.setHighTempBasalPercent(400);
|
danaRv2Plugin.setHighTempBasalPercent(400);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -7,6 +7,7 @@ import android.content.DialogInterface;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.graphics.DashPathEffect;
|
import android.graphics.DashPathEffect;
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.HandlerThread;
|
import android.os.HandlerThread;
|
||||||
|
@ -155,6 +156,8 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
TextView sage;
|
TextView sage;
|
||||||
TextView pbage;
|
TextView pbage;
|
||||||
|
|
||||||
|
TextView updating;
|
||||||
|
|
||||||
CheckBox showPredictionView;
|
CheckBox showPredictionView;
|
||||||
CheckBox showBasalsView;
|
CheckBox showBasalsView;
|
||||||
CheckBox showIobView;
|
CheckBox showIobView;
|
||||||
|
@ -246,6 +249,8 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
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);
|
||||||
|
|
||||||
|
updating = (TextView) view.findViewById(R.id.overview_updating);
|
||||||
|
|
||||||
bgGraph = (GraphView) view.findViewById(R.id.overview_bggraph);
|
bgGraph = (GraphView) view.findViewById(R.id.overview_bggraph);
|
||||||
iobGraph = (GraphView) view.findViewById(R.id.overview_iobgraph);
|
iobGraph = (GraphView) view.findViewById(R.id.overview_iobgraph);
|
||||||
|
|
||||||
|
@ -361,15 +366,15 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
switch (buttonView.getId()) {
|
switch (buttonView.getId()) {
|
||||||
case R.id.overview_showprediction:
|
case R.id.overview_showprediction:
|
||||||
SP.putBoolean("showprediction", showPredictionView.isChecked());
|
SP.putBoolean("showprediction", showPredictionView.isChecked());
|
||||||
scheduleUpdateGUI("onPredictionCheckedChanged");
|
updateGUI("onPredictionCheckedChanged");
|
||||||
break;
|
break;
|
||||||
case R.id.overview_showbasals:
|
case R.id.overview_showbasals:
|
||||||
SP.putBoolean("showbasals", showBasalsView.isChecked());
|
SP.putBoolean("showbasals", showBasalsView.isChecked());
|
||||||
scheduleUpdateGUI("onBasalsCheckedChanged");
|
updateGUI("onBasalsCheckedChanged");
|
||||||
break;
|
break;
|
||||||
case R.id.overview_showiob:
|
case R.id.overview_showiob:
|
||||||
SP.putBoolean("showiob", showIobView.isChecked());
|
SP.putBoolean("showiob", showIobView.isChecked());
|
||||||
scheduleUpdateGUI("onIobCheckedChanged");
|
updateGUI("onIobCheckedChanged");
|
||||||
break;
|
break;
|
||||||
case R.id.overview_showcob:
|
case R.id.overview_showcob:
|
||||||
showDeviationsView.setOnCheckedChangeListener(null);
|
showDeviationsView.setOnCheckedChangeListener(null);
|
||||||
|
@ -377,7 +382,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
showDeviationsView.setOnCheckedChangeListener(this);
|
showDeviationsView.setOnCheckedChangeListener(this);
|
||||||
SP.putBoolean("showcob", showCobView.isChecked());
|
SP.putBoolean("showcob", showCobView.isChecked());
|
||||||
SP.putBoolean("showdeviations", showDeviationsView.isChecked());
|
SP.putBoolean("showdeviations", showDeviationsView.isChecked());
|
||||||
scheduleUpdateGUI("onCobCheckedChanged");
|
updateGUI("onCobCheckedChanged");
|
||||||
break;
|
break;
|
||||||
case R.id.overview_showdeviations:
|
case R.id.overview_showdeviations:
|
||||||
showCobView.setOnCheckedChangeListener(null);
|
showCobView.setOnCheckedChangeListener(null);
|
||||||
|
@ -385,7 +390,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
showCobView.setOnCheckedChangeListener(this);
|
showCobView.setOnCheckedChangeListener(this);
|
||||||
SP.putBoolean("showcob", showCobView.isChecked());
|
SP.putBoolean("showcob", showCobView.isChecked());
|
||||||
SP.putBoolean("showdeviations", showDeviationsView.isChecked());
|
SP.putBoolean("showdeviations", showDeviationsView.isChecked());
|
||||||
scheduleUpdateGUI("onDeviationsCheckedChanged");
|
updateGUI("onDeviationsCheckedChanged");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -397,7 +402,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
activeloop.setFragmentEnabled(PluginBase.LOOP, false);
|
activeloop.setFragmentEnabled(PluginBase.LOOP, false);
|
||||||
activeloop.setFragmentVisible(PluginBase.LOOP, false);
|
activeloop.setFragmentVisible(PluginBase.LOOP, false);
|
||||||
MainApp.getConfigBuilder().storeSettings();
|
MainApp.getConfigBuilder().storeSettings();
|
||||||
scheduleUpdateGUI("suspendmenu");
|
updateGUI("suspendmenu");
|
||||||
sHandler.post(new Runnable() {
|
sHandler.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -413,12 +418,12 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
activeloop.setFragmentEnabled(PluginBase.LOOP, true);
|
activeloop.setFragmentEnabled(PluginBase.LOOP, true);
|
||||||
activeloop.setFragmentVisible(PluginBase.LOOP, true);
|
activeloop.setFragmentVisible(PluginBase.LOOP, true);
|
||||||
MainApp.getConfigBuilder().storeSettings();
|
MainApp.getConfigBuilder().storeSettings();
|
||||||
scheduleUpdateGUI("suspendmenu");
|
updateGUI("suspendmenu");
|
||||||
NSUpload.uploadOpenAPSOffline(0);
|
NSUpload.uploadOpenAPSOffline(0);
|
||||||
return true;
|
return true;
|
||||||
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.resume))) {
|
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.resume))) {
|
||||||
activeloop.suspendTo(0L);
|
activeloop.suspendTo(0L);
|
||||||
scheduleUpdateGUI("suspendmenu");
|
updateGUI("suspendmenu");
|
||||||
sHandler.post(new Runnable() {
|
sHandler.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -432,7 +437,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
return true;
|
return true;
|
||||||
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.suspendloopfor1h))) {
|
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.suspendloopfor1h))) {
|
||||||
activeloop.suspendTo(new Date().getTime() + 60L * 60 * 1000);
|
activeloop.suspendTo(new Date().getTime() + 60L * 60 * 1000);
|
||||||
scheduleUpdateGUI("suspendmenu");
|
updateGUI("suspendmenu");
|
||||||
sHandler.post(new Runnable() {
|
sHandler.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -446,7 +451,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
return true;
|
return true;
|
||||||
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.suspendloopfor2h))) {
|
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.suspendloopfor2h))) {
|
||||||
activeloop.suspendTo(new Date().getTime() + 2 * 60L * 60 * 1000);
|
activeloop.suspendTo(new Date().getTime() + 2 * 60L * 60 * 1000);
|
||||||
scheduleUpdateGUI("suspendmenu");
|
updateGUI("suspendmenu");
|
||||||
sHandler.post(new Runnable() {
|
sHandler.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -474,7 +479,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
return true;
|
return true;
|
||||||
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.suspendloopfor10h))) {
|
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.suspendloopfor10h))) {
|
||||||
activeloop.suspendTo(new Date().getTime() + 10 * 60L * 60 * 1000);
|
activeloop.suspendTo(new Date().getTime() + 10 * 60L * 60 * 1000);
|
||||||
scheduleUpdateGUI("suspendmenu");
|
updateGUI("suspendmenu");
|
||||||
sHandler.post(new Runnable() {
|
sHandler.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -488,7 +493,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
return true;
|
return true;
|
||||||
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.disconnectpumpfor30m))) {
|
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.disconnectpumpfor30m))) {
|
||||||
activeloop.suspendTo(new Date().getTime() + 30L * 60 * 1000);
|
activeloop.suspendTo(new Date().getTime() + 30L * 60 * 1000);
|
||||||
scheduleUpdateGUI("suspendmenu");
|
updateGUI("suspendmenu");
|
||||||
sHandler.post(new Runnable() {
|
sHandler.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -502,7 +507,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
return true;
|
return true;
|
||||||
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.disconnectpumpfor1h))) {
|
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.disconnectpumpfor1h))) {
|
||||||
activeloop.suspendTo(new Date().getTime() + 1 * 60L * 60 * 1000);
|
activeloop.suspendTo(new Date().getTime() + 1 * 60L * 60 * 1000);
|
||||||
scheduleUpdateGUI("suspendmenu");
|
updateGUI("suspendmenu");
|
||||||
sHandler.post(new Runnable() {
|
sHandler.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -516,7 +521,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
return true;
|
return true;
|
||||||
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.disconnectpumpfor2h))) {
|
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.disconnectpumpfor2h))) {
|
||||||
activeloop.suspendTo(new Date().getTime() + 2 * 60L * 60 * 1000);
|
activeloop.suspendTo(new Date().getTime() + 2 * 60L * 60 * 1000);
|
||||||
scheduleUpdateGUI("suspendmenu");
|
updateGUI("suspendmenu");
|
||||||
sHandler.post(new Runnable() {
|
sHandler.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -530,7 +535,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
return true;
|
return true;
|
||||||
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.disconnectpumpfor3h))) {
|
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.disconnectpumpfor3h))) {
|
||||||
activeloop.suspendTo(new Date().getTime() + 3 * 60L * 60 * 1000);
|
activeloop.suspendTo(new Date().getTime() + 3 * 60L * 60 * 1000);
|
||||||
scheduleUpdateGUI("suspendmenu");
|
updateGUI("suspendmenu");
|
||||||
sHandler.post(new Runnable() {
|
sHandler.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -879,39 +884,79 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
if (scheduledUpdate != null)
|
if (scheduledUpdate != null)
|
||||||
scheduledUpdate.cancel(false);
|
scheduledUpdate.cancel(false);
|
||||||
Runnable task = new UpdateRunnable();
|
Runnable task = new UpdateRunnable();
|
||||||
final int msec = 400;
|
final int msec = 2000;
|
||||||
scheduledUpdate = worker.schedule(task, msec, TimeUnit.MILLISECONDS);
|
scheduledUpdate = worker.schedule(task, msec, TimeUnit.MILLISECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("SetTextI18n")
|
private class updateGUIAsyncClass extends AsyncTask<String, Void, String> {
|
||||||
public void updateGUI(String from) {
|
|
||||||
log.debug("updateGUI entered from: " + from);
|
|
||||||
if (MainApp.getConfigBuilder().getProfile() == null) {// app not initialized yet
|
|
||||||
pumpStatusView.setText(R.string.noprofileset);
|
|
||||||
pumpStatusLayout.setVisibility(View.VISIBLE);
|
|
||||||
loopStatusLayout.setVisibility(View.GONE);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
pumpStatusLayout.setVisibility(View.GONE);
|
|
||||||
loopStatusLayout.setVisibility(View.VISIBLE);
|
|
||||||
|
|
||||||
updateNotifications();
|
|
||||||
CareportalFragment.updateAge(getActivity(), sage, iage, cage, pbage);
|
|
||||||
BgReading actualBG = DatabaseHelper.actualBg();
|
BgReading actualBG = DatabaseHelper.actualBg();
|
||||||
BgReading lastBG = DatabaseHelper.lastBg();
|
BgReading lastBG = DatabaseHelper.lastBg();
|
||||||
|
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||||
|
String units = profile.getUnits();
|
||||||
|
final LoopPlugin.LastRun finalLastRun = LoopPlugin.lastRun;
|
||||||
|
|
||||||
PumpInterface pump = MainApp.getConfigBuilder();
|
PumpInterface pump = MainApp.getConfigBuilder();
|
||||||
|
|
||||||
// Skip if not initialized yet
|
long now = new Date().getTime();
|
||||||
if (bgGraph == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
IobTotal bolusIob;
|
||||||
if (getActivity() == null)
|
IobTotal basalIob;
|
||||||
return;
|
|
||||||
|
|
||||||
|
Double lowLine;
|
||||||
|
Double highLine;
|
||||||
|
|
||||||
|
int hoursToFetch;
|
||||||
|
long toTime;
|
||||||
|
long fromTime;
|
||||||
|
long endTime;
|
||||||
|
|
||||||
|
boolean showPrediction;
|
||||||
|
boolean showBasals;
|
||||||
|
boolean showIob;
|
||||||
|
boolean showCob;
|
||||||
|
boolean showDeviations;
|
||||||
|
|
||||||
|
LineGraphSeries<DataPoint> basalsLineSeries;
|
||||||
|
LineGraphSeries<DataPoint> absoluteBasalsLineSeries;
|
||||||
|
LineGraphSeries<DataPoint> baseBasalsSeries;
|
||||||
|
LineGraphSeries<DataPoint> tempBasalsSeries;
|
||||||
|
AreaGraphSeries<DoubleDataPoint> areaSeries;
|
||||||
|
LineGraphSeries<DataPoint> seriesNow, seriesNow2;
|
||||||
|
PointsWithLabelGraphSeries<DataPointWithLabelInterface> bgSeries = null;
|
||||||
|
PointsWithLabelGraphSeries<DataPointWithLabelInterface> treatmentSeries = null;
|
||||||
|
|
||||||
|
class DeviationDataPoint extends DataPoint {
|
||||||
|
public int color;
|
||||||
|
|
||||||
|
public DeviationDataPoint(double x, double y, int color) {
|
||||||
|
super(x, y);
|
||||||
|
this.color = color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FixedLineGraphSeries<DataPoint> iobSeries;
|
||||||
|
FixedLineGraphSeries<DataPoint> cobSeries;
|
||||||
|
BarGraphSeries<DeviationDataPoint> devSeries;
|
||||||
|
DataPoint[] cobData;
|
||||||
|
DeviationDataPoint[] devData;
|
||||||
|
|
||||||
|
List<BgReading> bgReadingsArray;
|
||||||
|
Double maxBgValue = 0d;
|
||||||
|
Double maxIobValueFound = 0d;
|
||||||
|
Double maxCobValueFound = 0d;
|
||||||
|
Double maxDevValueFound = 0d;
|
||||||
|
Double maxBasalValueFound = 0d;
|
||||||
|
|
||||||
|
Integer numOfHorizLines;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPreExecute() {
|
||||||
|
log.debug("updateGUIAsyncClass onPreExecute");
|
||||||
|
updating.setVisibility(View.VISIBLE);
|
||||||
|
updateNotifications();
|
||||||
|
CareportalFragment.updateAge(getActivity(), sage, iage, cage, pbage);
|
||||||
// open loop mode
|
// open loop mode
|
||||||
final LoopPlugin.LastRun finalLastRun = LoopPlugin.lastRun;
|
|
||||||
if (Config.APS && MainApp.getConfigBuilder().getPumpDescription().isTempBasalCapable) {
|
if (Config.APS && MainApp.getConfigBuilder().getPumpDescription().isTempBasalCapable) {
|
||||||
apsModeView.setVisibility(View.VISIBLE);
|
apsModeView.setVisibility(View.VISIBLE);
|
||||||
apsModeView.setBackgroundColor(MainApp.sResources.getColor(R.color.loopenabled));
|
apsModeView.setBackgroundColor(MainApp.sResources.getColor(R.color.loopenabled));
|
||||||
|
@ -1075,8 +1120,8 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
|
|
||||||
String units = profile.getUnits();
|
String units = profile.getUnits();
|
||||||
|
|
||||||
Double lowLine = SP.getDouble("low_mark", 0d);
|
lowLine = SP.getDouble("low_mark", 0d);
|
||||||
Double highLine = SP.getDouble("high_mark", 0d);
|
highLine = SP.getDouble("high_mark", 0d);
|
||||||
if (lowLine < 1) {
|
if (lowLine < 1) {
|
||||||
lowLine = Profile.fromMgdlToUnits(OverviewPlugin.bgTargetLow, units);
|
lowLine = Profile.fromMgdlToUnits(OverviewPlugin.bgTargetLow, units);
|
||||||
}
|
}
|
||||||
|
@ -1122,17 +1167,6 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
int agoMin = (int) (agoMsec / 60d / 1000d);
|
int agoMin = (int) (agoMsec / 60d / 1000d);
|
||||||
timeAgoView.setText(String.format(MainApp.sResources.getString(R.string.minago), agoMin));
|
timeAgoView.setText(String.format(MainApp.sResources.getString(R.string.minago), agoMin));
|
||||||
|
|
||||||
// iob
|
|
||||||
MainApp.getConfigBuilder().updateTotalIOBTreatments();
|
|
||||||
MainApp.getConfigBuilder().updateTotalIOBTempBasals();
|
|
||||||
IobTotal bolusIob = MainApp.getConfigBuilder().getLastCalculationTreatments().round();
|
|
||||||
IobTotal basalIob = MainApp.getConfigBuilder().getLastCalculationTempBasals().round();
|
|
||||||
|
|
||||||
String iobtext = getString(R.string.treatments_iob_label_string) + " " + DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob) + "U ("
|
|
||||||
+ getString(R.string.bolus) + ": " + DecimalFormatter.to2Decimal(bolusIob.iob) + "U "
|
|
||||||
+ getString(R.string.basal) + ": " + DecimalFormatter.to2Decimal(basalIob.basaliob) + "U)";
|
|
||||||
iobView.setText(iobtext);
|
|
||||||
|
|
||||||
// cob
|
// cob
|
||||||
if (cobView != null) { // view must not exists
|
if (cobView != null) { // view must not exists
|
||||||
String cobText = "";
|
String cobText = "";
|
||||||
|
@ -1142,7 +1176,6 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
cobView.setText(cobText);
|
cobView.setText(cobText);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean showPrediction = showPredictionView.isChecked() && finalLastRun != null && finalLastRun.constraintsProcessed.getClass().equals(DetermineBasalResultAMA.class);
|
|
||||||
if (MainApp.getSpecificPlugin(OpenAPSAMAPlugin.class) != null && MainApp.getSpecificPlugin(OpenAPSAMAPlugin.class).isEnabled(PluginBase.APS)) {
|
if (MainApp.getSpecificPlugin(OpenAPSAMAPlugin.class) != null && MainApp.getSpecificPlugin(OpenAPSAMAPlugin.class).isEnabled(PluginBase.APS)) {
|
||||||
showPredictionView.setVisibility(View.VISIBLE);
|
showPredictionView.setVisibility(View.VISIBLE);
|
||||||
getActivity().findViewById(R.id.overview_showprediction_label).setVisibility(View.VISIBLE);
|
getActivity().findViewById(R.id.overview_showprediction_label).setVisibility(View.VISIBLE);
|
||||||
|
@ -1161,10 +1194,12 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
calendar.set(Calendar.MINUTE, 0);
|
calendar.set(Calendar.MINUTE, 0);
|
||||||
calendar.add(Calendar.HOUR, 1);
|
calendar.add(Calendar.HOUR, 1);
|
||||||
|
|
||||||
int hoursToFetch;
|
showPrediction = showPredictionView.isChecked() && finalLastRun != null && finalLastRun.constraintsProcessed.getClass().equals(DetermineBasalResultAMA.class);
|
||||||
long toTime;
|
showBasals = showBasalsView.isChecked();
|
||||||
long fromTime;
|
showIob = showIobView.isChecked();
|
||||||
long endTime;
|
showCob = showCobView.isChecked();
|
||||||
|
showDeviations = showDeviationsView.isChecked();
|
||||||
|
|
||||||
if (showPrediction) {
|
if (showPrediction) {
|
||||||
int predHours = (int) (Math.ceil(((DetermineBasalResultAMA) finalLastRun.constraintsProcessed).getLatestPredictionsTime() - new Date().getTime()) / (60 * 60 * 1000));
|
int predHours = (int) (Math.ceil(((DetermineBasalResultAMA) finalLastRun.constraintsProcessed).getLatestPredictionsTime() - new Date().getTime()) / (60 * 60 * 1000));
|
||||||
predHours = Math.min(2, predHours);
|
predHours = Math.min(2, predHours);
|
||||||
|
@ -1180,18 +1215,45 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
endTime = toTime;
|
endTime = toTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
LineGraphSeries<DataPoint> basalsLineSeries = null;
|
// **** HIGH and LOW targets graph ****
|
||||||
LineGraphSeries<DataPoint> absoluteBasalsLineSeries = null;
|
DoubleDataPoint[] areaDataPoints = new DoubleDataPoint[]{
|
||||||
LineGraphSeries<DataPoint> baseBasalsSeries = null;
|
new DoubleDataPoint(fromTime, lowLine, highLine),
|
||||||
LineGraphSeries<DataPoint> tempBasalsSeries = null;
|
new DoubleDataPoint(endTime, lowLine, highLine)
|
||||||
AreaGraphSeries<DoubleDataPoint> areaSeries;
|
};
|
||||||
LineGraphSeries<DataPoint> seriesNow, seriesNow2;
|
bgGraph.addSeries(areaSeries = new AreaGraphSeries<>(areaDataPoints));
|
||||||
|
areaSeries.setColor(0);
|
||||||
|
areaSeries.setDrawBackground(true);
|
||||||
|
areaSeries.setBackgroundColor(Color.argb(40, 0, 255, 0));
|
||||||
|
|
||||||
|
// set manual x bounds to have nice steps
|
||||||
|
bgGraph.getViewport().setMaxX(endTime);
|
||||||
|
bgGraph.getViewport().setMinX(fromTime);
|
||||||
|
bgGraph.getViewport().setXAxisBoundsManual(true);
|
||||||
|
bgGraph.getGridLabelRenderer().setLabelFormatter(new TimeAsXAxisLabelFormatter(getActivity(), "HH"));
|
||||||
|
bgGraph.getGridLabelRenderer().setNumHorizontalLabels(7); // only 7 because of the space
|
||||||
|
iobGraph.getViewport().setMaxX(endTime);
|
||||||
|
iobGraph.getViewport().setMinX(fromTime);
|
||||||
|
iobGraph.getViewport().setXAxisBoundsManual(true);
|
||||||
|
iobGraph.getGridLabelRenderer().setLabelFormatter(new TimeAsXAxisLabelFormatter(getActivity(), "HH"));
|
||||||
|
iobGraph.getGridLabelRenderer().setNumHorizontalLabels(7); // only 7 because of the space
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String doInBackground(String... params) {
|
||||||
|
log.debug("updateGUIAsyncClass starting background calculations from: " + params[0]);
|
||||||
|
|
||||||
|
// IOB
|
||||||
|
MainApp.getConfigBuilder().updateTotalIOBTreatments();
|
||||||
|
MainApp.getConfigBuilder().updateTotalIOBTempBasals();
|
||||||
|
bolusIob = MainApp.getConfigBuilder().getLastCalculationTreatments().round();
|
||||||
|
basalIob = MainApp.getConfigBuilder().getLastCalculationTempBasals().round();
|
||||||
|
|
||||||
|
// ****** GRAPH *******
|
||||||
|
|
||||||
// **** TEMP BASALS graph ****
|
// **** TEMP BASALS graph ****
|
||||||
Double maxBasalValueFound = 0d;
|
|
||||||
|
|
||||||
long now = new Date().getTime();
|
if (pump.getPumpDescription().isTempBasalCapable && showBasals) {
|
||||||
if (pump.getPumpDescription().isTempBasalCapable && showBasalsView.isChecked()) {
|
|
||||||
List<DataPoint> baseBasalArray = new ArrayList<>();
|
List<DataPoint> baseBasalArray = new ArrayList<>();
|
||||||
List<DataPoint> tempBasalArray = new ArrayList<>();
|
List<DataPoint> tempBasalArray = new ArrayList<>();
|
||||||
List<DataPoint> basalLineArray = new ArrayList<>();
|
List<DataPoint> basalLineArray = new ArrayList<>();
|
||||||
|
@ -1284,39 +1346,25 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
}
|
}
|
||||||
|
|
||||||
// **** IOB COB DEV graph ****
|
// **** IOB COB DEV graph ****
|
||||||
class DeviationDataPoint extends DataPoint {
|
|
||||||
public int color;
|
|
||||||
|
|
||||||
public DeviationDataPoint(double x, double y, int color) {
|
if (showIob || showCob || showDeviations) {
|
||||||
super(x, y);
|
|
||||||
this.color = color;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
FixedLineGraphSeries<DataPoint> iobSeries;
|
|
||||||
FixedLineGraphSeries<DataPoint> cobSeries;
|
|
||||||
BarGraphSeries<DeviationDataPoint> devSeries;
|
|
||||||
Double maxIobValueFound = 0d;
|
|
||||||
Double maxCobValueFound = 0d;
|
|
||||||
Double maxDevValueFound = 0d;
|
|
||||||
|
|
||||||
if (showIobView.isChecked() || showCobView.isChecked() || showDeviationsView.isChecked()) {
|
|
||||||
//Date start = new Date();
|
//Date start = new Date();
|
||||||
List<DataPoint> iobArray = new ArrayList<>();
|
List<DataPoint> iobArray = new ArrayList<>();
|
||||||
List<DataPoint> cobArray = new ArrayList<>();
|
List<DataPoint> cobArray = new ArrayList<>();
|
||||||
List<DeviationDataPoint> devArray = new ArrayList<>();
|
List<DeviationDataPoint> devArray = new ArrayList<>();
|
||||||
for (long time = fromTime; time <= now; time += 5 * 60 * 1000L) {
|
for (long time = fromTime; time <= now; time += 5 * 60 * 1000L) {
|
||||||
if (showIobView.isChecked()) {
|
if (showIob) {
|
||||||
IobTotal iob = IobCobCalculatorPlugin.calulateFromTreatmentsAndTemps(time);
|
IobTotal iob = IobCobCalculatorPlugin.calulateFromTreatmentsAndTemps(time);
|
||||||
iobArray.add(new DataPoint(time, iob.iob));
|
iobArray.add(new DataPoint(time, iob.iob));
|
||||||
maxIobValueFound = Math.max(maxIobValueFound, Math.abs(iob.iob));
|
maxIobValueFound = Math.max(maxIobValueFound, Math.abs(iob.iob));
|
||||||
}
|
}
|
||||||
if (showCobView.isChecked() || showDeviationsView.isChecked()) {
|
if (showCob || showDeviations) {
|
||||||
AutosensData autosensData = IobCobCalculatorPlugin.getAutosensData(time);
|
AutosensData autosensData = IobCobCalculatorPlugin.getAutosensData(time);
|
||||||
if (autosensData != null && showCobView.isChecked()) {
|
if (autosensData != null && showCob) {
|
||||||
cobArray.add(new DataPoint(time, autosensData.cob));
|
cobArray.add(new DataPoint(time, autosensData.cob));
|
||||||
maxCobValueFound = Math.max(maxCobValueFound, autosensData.cob);
|
maxCobValueFound = Math.max(maxCobValueFound, autosensData.cob);
|
||||||
}
|
}
|
||||||
if (autosensData != null && showDeviationsView.isChecked()) {
|
if (autosensData != null && showDeviations) {
|
||||||
int color = Color.BLACK; // "="
|
int color = Color.BLACK; // "="
|
||||||
if (autosensData.pastSensitivity.equals("C")) color = Color.GRAY;
|
if (autosensData.pastSensitivity.equals("C")) color = Color.GRAY;
|
||||||
if (autosensData.pastSensitivity.equals("+")) color = Color.GREEN;
|
if (autosensData.pastSensitivity.equals("+")) color = Color.GREEN;
|
||||||
|
@ -1336,7 +1384,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
iobSeries.setThickness(3);
|
iobSeries.setThickness(3);
|
||||||
|
|
||||||
|
|
||||||
if (showIobView.isChecked() && (showCobView.isChecked() || showDeviationsView.isChecked())) {
|
if (showIob && (showCob || showDeviations)) {
|
||||||
List<DataPoint> cobArrayRescaled = new ArrayList<>();
|
List<DataPoint> cobArrayRescaled = new ArrayList<>();
|
||||||
List<DeviationDataPoint> devArrayRescaled = new ArrayList<>();
|
List<DeviationDataPoint> devArrayRescaled = new ArrayList<>();
|
||||||
for (int ci = 0; ci < cobArray.size(); ci++) {
|
for (int ci = 0; ci < cobArray.size(); ci++) {
|
||||||
|
@ -1349,7 +1397,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
devArray = devArrayRescaled;
|
devArray = devArrayRescaled;
|
||||||
}
|
}
|
||||||
// COB
|
// COB
|
||||||
DataPoint[] cobData = new DataPoint[cobArray.size()];
|
cobData = new DataPoint[cobArray.size()];
|
||||||
cobData = cobArray.toArray(cobData);
|
cobData = cobArray.toArray(cobData);
|
||||||
cobSeries = new FixedLineGraphSeries<>(cobData);
|
cobSeries = new FixedLineGraphSeries<>(cobData);
|
||||||
cobSeries.setDrawBackground(true);
|
cobSeries.setDrawBackground(true);
|
||||||
|
@ -1358,7 +1406,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
cobSeries.setThickness(3);
|
cobSeries.setThickness(3);
|
||||||
|
|
||||||
// DEVIATIONS
|
// DEVIATIONS
|
||||||
DeviationDataPoint[] devData = new DeviationDataPoint[devArray.size()];
|
devData = new DeviationDataPoint[devArray.size()];
|
||||||
devData = devArray.toArray(devData);
|
devData = devArray.toArray(devData);
|
||||||
devSeries = new BarGraphSeries<>(devData);
|
devSeries = new BarGraphSeries<>(devData);
|
||||||
devSeries.setValueDependentColor(new ValueDependentColor<DeviationDataPoint>() {
|
devSeries.setValueDependentColor(new ValueDependentColor<DeviationDataPoint>() {
|
||||||
|
@ -1367,61 +1415,13 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
return data.color;
|
return data.color;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
//devSeries.setBackgroundColor(0xB0FFFFFF & MainApp.sResources.getColor(R.color.cob)); //50%
|
|
||||||
//devSeries.setColor(MainApp.sResources.getColor(R.color.cob));
|
|
||||||
//devSeries.setThickness(3);
|
|
||||||
|
|
||||||
iobGraph.removeAllSeries();
|
|
||||||
|
|
||||||
if (showIobView.isChecked()) {
|
|
||||||
iobGraph.addSeries(iobSeries);
|
|
||||||
}
|
}
|
||||||
if (showCobView.isChecked() && cobData.length > 0) {
|
|
||||||
iobGraph.addSeries(cobSeries);
|
|
||||||
}
|
|
||||||
if (showDeviationsView.isChecked() && devData.length > 0) {
|
|
||||||
iobGraph.addSeries(devSeries);
|
|
||||||
}
|
|
||||||
iobGraph.setVisibility(View.VISIBLE);
|
|
||||||
} else {
|
|
||||||
iobGraph.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
// remove old data from graph
|
|
||||||
bgGraph.getSecondScale().getSeries().clear();
|
|
||||||
bgGraph.removeAllSeries();
|
|
||||||
|
|
||||||
// **** HIGH and LOW targets graph ****
|
|
||||||
DoubleDataPoint[] areaDataPoints = new DoubleDataPoint[]{
|
|
||||||
new DoubleDataPoint(fromTime, lowLine, highLine),
|
|
||||||
new DoubleDataPoint(endTime, lowLine, highLine)
|
|
||||||
};
|
|
||||||
bgGraph.addSeries(areaSeries = new AreaGraphSeries<>(areaDataPoints));
|
|
||||||
areaSeries.setColor(0);
|
|
||||||
areaSeries.setDrawBackground(true);
|
|
||||||
areaSeries.setBackgroundColor(Color.argb(40, 0, 255, 0));
|
|
||||||
|
|
||||||
// set manual x bounds to have nice steps
|
|
||||||
bgGraph.getViewport().setMaxX(endTime);
|
|
||||||
bgGraph.getViewport().setMinX(fromTime);
|
|
||||||
bgGraph.getViewport().setXAxisBoundsManual(true);
|
|
||||||
bgGraph.getGridLabelRenderer().setLabelFormatter(new TimeAsXAxisLabelFormatter(getActivity(), "HH"));
|
|
||||||
bgGraph.getGridLabelRenderer().setNumHorizontalLabels(7); // only 7 because of the space
|
|
||||||
iobGraph.getViewport().setMaxX(endTime);
|
|
||||||
iobGraph.getViewport().setMinX(fromTime);
|
|
||||||
iobGraph.getViewport().setXAxisBoundsManual(true);
|
|
||||||
iobGraph.getGridLabelRenderer().setLabelFormatter(new TimeAsXAxisLabelFormatter(getActivity(), "HH"));
|
|
||||||
iobGraph.getGridLabelRenderer().setNumHorizontalLabels(7); // only 7 because of the space
|
|
||||||
|
|
||||||
// **** BG graph ****
|
// **** BG graph ****
|
||||||
List<BgReading> bgReadingsArray = MainApp.getDbHelper().getBgreadingsDataFromTime(fromTime, true);
|
bgReadingsArray = MainApp.getDbHelper().getBgreadingsDataFromTime(fromTime, true);
|
||||||
List<DataPointWithLabelInterface> bgListArray = new ArrayList<>();
|
List<DataPointWithLabelInterface> bgListArray = new ArrayList<>();
|
||||||
|
|
||||||
if (bgReadingsArray.size() == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
Iterator<BgReading> it = bgReadingsArray.iterator();
|
Iterator<BgReading> it = bgReadingsArray.iterator();
|
||||||
Double maxBgValue = 0d;
|
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
BgReading bg = it.next();
|
BgReading bg = it.next();
|
||||||
if (bg.value > maxBgValue) maxBgValue = bg.value;
|
if (bg.value > maxBgValue) maxBgValue = bg.value;
|
||||||
|
@ -1440,13 +1440,86 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
maxBgValue = Profile.fromMgdlToUnits(maxBgValue, units);
|
maxBgValue = Profile.fromMgdlToUnits(maxBgValue, units);
|
||||||
maxBgValue = units.equals(Constants.MGDL) ? Round.roundTo(maxBgValue, 40d) + 80 : Round.roundTo(maxBgValue, 2d) + 4;
|
maxBgValue = units.equals(Constants.MGDL) ? Round.roundTo(maxBgValue, 40d) + 80 : Round.roundTo(maxBgValue, 2d) + 4;
|
||||||
if (highLine > maxBgValue) maxBgValue = highLine;
|
if (highLine > maxBgValue) maxBgValue = highLine;
|
||||||
Integer numOfHorizLines = units.equals(Constants.MGDL) ? (int) (maxBgValue / 40 + 1) : (int) (maxBgValue / 2 + 1);
|
numOfHorizLines = units.equals(Constants.MGDL) ? (int) (maxBgValue / 40 + 1) : (int) (maxBgValue / 2 + 1);
|
||||||
|
|
||||||
DataPointWithLabelInterface[] bg = new DataPointWithLabelInterface[bgListArray.size()];
|
DataPointWithLabelInterface[] bg = new DataPointWithLabelInterface[bgListArray.size()];
|
||||||
bg = bgListArray.toArray(bg);
|
bg = bgListArray.toArray(bg);
|
||||||
|
if (bg.length > 0)
|
||||||
|
bgSeries = new PointsWithLabelGraphSeries<>(bg);
|
||||||
|
|
||||||
if (bg.length > 0) {
|
// **** treatments graph ****
|
||||||
bgGraph.addSeries(new PointsWithLabelGraphSeries<>(bg));
|
List<DataPointWithLabelInterface> filteredTreatments = new ArrayList<>();
|
||||||
|
|
||||||
|
List<Treatment> treatments = MainApp.getConfigBuilder().getTreatmentsFromHistory();
|
||||||
|
|
||||||
|
for (int tx = 0; tx < treatments.size(); tx++) {
|
||||||
|
DataPointWithLabelInterface t = treatments.get(tx);
|
||||||
|
if (t.getX() < fromTime || t.getX() > endTime) continue;
|
||||||
|
t.setY(getNearestBg((long) t.getX(), bgReadingsArray));
|
||||||
|
filteredTreatments.add(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ProfileSwitch
|
||||||
|
List<ProfileSwitch> profileSwitches = MainApp.getConfigBuilder().getProfileSwitchesFromHistory().getList();
|
||||||
|
|
||||||
|
for (int tx = 0; tx < profileSwitches.size(); tx++) {
|
||||||
|
DataPointWithLabelInterface t = profileSwitches.get(tx);
|
||||||
|
if (t.getX() < fromTime || t.getX() > endTime) continue;
|
||||||
|
filteredTreatments.add(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
DataPointWithLabelInterface[] treatmentsArray = new DataPointWithLabelInterface[filteredTreatments.size()];
|
||||||
|
treatmentsArray = filteredTreatments.toArray(treatmentsArray);
|
||||||
|
if (treatmentsArray.length > 0) {
|
||||||
|
treatmentSeries = new PointsWithLabelGraphSeries<>(treatmentsArray);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return params[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPostExecute(String result) {
|
||||||
|
log.debug("updateGUIAsyncClass onPostExecute");
|
||||||
|
// IOB
|
||||||
|
String iobtext = getString(R.string.treatments_iob_label_string) + " " + DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob) + "U ("
|
||||||
|
+ getString(R.string.bolus) + ": " + DecimalFormatter.to2Decimal(bolusIob.iob) + "U "
|
||||||
|
+ getString(R.string.basal) + ": " + DecimalFormatter.to2Decimal(basalIob.basaliob) + "U)";
|
||||||
|
iobView.setText(iobtext);
|
||||||
|
|
||||||
|
// ****** GRAPH *******
|
||||||
|
|
||||||
|
// **** IOB COB DEV graph ****
|
||||||
|
if (showIob || showCob || showDeviations) {
|
||||||
|
iobGraph.removeAllSeries();
|
||||||
|
|
||||||
|
if (showIob) {
|
||||||
|
iobGraph.addSeries(iobSeries);
|
||||||
|
}
|
||||||
|
if (showCob && cobData.length > 0) {
|
||||||
|
iobGraph.addSeries(cobSeries);
|
||||||
|
}
|
||||||
|
if (showDeviations && devData.length > 0) {
|
||||||
|
iobGraph.addSeries(devSeries);
|
||||||
|
}
|
||||||
|
iobGraph.setVisibility(View.VISIBLE);
|
||||||
|
} else {
|
||||||
|
iobGraph.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
// remove old data from graph
|
||||||
|
bgGraph.getSecondScale().getSeries().clear();
|
||||||
|
bgGraph.removeAllSeries();
|
||||||
|
|
||||||
|
// **** BG graph ****
|
||||||
|
|
||||||
|
if (bgSeries != null) {
|
||||||
|
bgGraph.addSeries(bgSeries);
|
||||||
|
}
|
||||||
|
|
||||||
|
// **** treatments graph ****
|
||||||
|
if (treatmentSeries != null) {
|
||||||
|
bgGraph.addSeries(treatmentSeries);
|
||||||
}
|
}
|
||||||
|
|
||||||
// **** NOW line ****
|
// **** NOW line ****
|
||||||
|
@ -1472,34 +1545,6 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
seriesNow.setCustomPaint(paint);
|
seriesNow.setCustomPaint(paint);
|
||||||
seriesNow2.setCustomPaint(paint);
|
seriesNow2.setCustomPaint(paint);
|
||||||
|
|
||||||
|
|
||||||
// Treatments
|
|
||||||
List<DataPointWithLabelInterface> filteredTreatments = new ArrayList<>();
|
|
||||||
|
|
||||||
List<Treatment> treatments = MainApp.getConfigBuilder().getTreatmentsFromHistory();
|
|
||||||
|
|
||||||
for (int tx = 0; tx < treatments.size(); tx++) {
|
|
||||||
DataPointWithLabelInterface t = treatments.get(tx);
|
|
||||||
if (t.getX() < fromTime || t.getX() > endTime) continue;
|
|
||||||
t.setY(getNearestBg((long) t.getX(), bgReadingsArray));
|
|
||||||
filteredTreatments.add(t);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ProfileSwitch
|
|
||||||
List<ProfileSwitch> profileSwitches = MainApp.getConfigBuilder().getProfileSwitchesFromHistory().getList();
|
|
||||||
|
|
||||||
for (int tx = 0; tx < profileSwitches.size(); tx++) {
|
|
||||||
DataPointWithLabelInterface t = profileSwitches.get(tx);
|
|
||||||
if (t.getX() < fromTime || t.getX() > endTime) continue;
|
|
||||||
filteredTreatments.add(t);
|
|
||||||
}
|
|
||||||
|
|
||||||
DataPointWithLabelInterface[] treatmentsArray = new DataPointWithLabelInterface[filteredTreatments.size()];
|
|
||||||
treatmentsArray = filteredTreatments.toArray(treatmentsArray);
|
|
||||||
if (treatmentsArray.length > 0) {
|
|
||||||
bgGraph.addSeries(new PointsWithLabelGraphSeries<>(treatmentsArray));
|
|
||||||
}
|
|
||||||
|
|
||||||
// set manual y bounds to have nice steps
|
// set manual y bounds to have nice steps
|
||||||
bgGraph.getViewport().setMaxY(maxBgValue);
|
bgGraph.getViewport().setMaxY(maxBgValue);
|
||||||
bgGraph.getViewport().setMinY(0);
|
bgGraph.getViewport().setMinY(0);
|
||||||
|
@ -1507,7 +1552,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
bgGraph.getGridLabelRenderer().setNumVerticalLabels(numOfHorizLines);
|
bgGraph.getGridLabelRenderer().setNumVerticalLabels(numOfHorizLines);
|
||||||
|
|
||||||
// set second scale
|
// set second scale
|
||||||
if (pump.getPumpDescription().isTempBasalCapable && showBasalsView.isChecked()) {
|
if (pump.getPumpDescription().isTempBasalCapable && showBasals) {
|
||||||
bgGraph.getSecondScale().addSeries(baseBasalsSeries);
|
bgGraph.getSecondScale().addSeries(baseBasalsSeries);
|
||||||
bgGraph.getSecondScale().addSeries(tempBasalsSeries);
|
bgGraph.getSecondScale().addSeries(tempBasalsSeries);
|
||||||
bgGraph.getSecondScale().addSeries(basalsLineSeries);
|
bgGraph.getSecondScale().addSeries(basalsLineSeries);
|
||||||
|
@ -1526,7 +1571,27 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
updating.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateGUIAsync(String from) {
|
||||||
|
new updateGUIAsyncClass().execute(from);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressLint("SetTextI18n")
|
||||||
|
public void updateGUI(String from) {
|
||||||
|
log.debug("updateGUI entered from: " + from);
|
||||||
|
if (MainApp.getConfigBuilder().getProfile() == null) {// app not initialized yet
|
||||||
|
pumpStatusView.setText(R.string.noprofileset);
|
||||||
|
pumpStatusLayout.setVisibility(View.VISIBLE);
|
||||||
|
loopStatusLayout.setVisibility(View.GONE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
pumpStatusLayout.setVisibility(View.GONE);
|
||||||
|
loopStatusLayout.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
|
updateGUIAsync(from);
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getNearestBg(long date, List<BgReading> bgReadingsArray) {
|
public double getNearestBg(long date, List<BgReading> bgReadingsArray) {
|
||||||
|
|
|
@ -294,10 +294,30 @@
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
<com.jjoe64.graphview.GraphView
|
<com.jjoe64.graphview.GraphView
|
||||||
android:id="@+id/overview_bggraph"
|
android:id="@+id/overview_bggraph"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="160dip" />
|
android:layout_height="160dip"
|
||||||
|
android:layout_alignParentStart="true"
|
||||||
|
android:layout_alignParentTop="true" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/overview_updating"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
|
android:layout_centerInParent="true"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:text="@string/updating"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||||
|
android:textColor="@color/updating"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
<com.jjoe64.graphview.GraphView
|
<com.jjoe64.graphview.GraphView
|
||||||
android:id="@+id/overview_iobgraph"
|
android:id="@+id/overview_iobgraph"
|
||||||
|
|
|
@ -294,10 +294,30 @@
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
<com.jjoe64.graphview.GraphView
|
<com.jjoe64.graphview.GraphView
|
||||||
android:id="@+id/overview_bggraph"
|
android:id="@+id/overview_bggraph"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="160dip" />
|
android:layout_height="160dip"
|
||||||
|
android:layout_alignParentStart="true"
|
||||||
|
android:layout_alignParentTop="true" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/overview_updating"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
|
android:layout_centerInParent="true"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:text="@string/updating"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||||
|
android:textColor="@color/updating"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
<com.jjoe64.graphview.GraphView
|
<com.jjoe64.graphview.GraphView
|
||||||
android:id="@+id/overview_iobgraph"
|
android:id="@+id/overview_iobgraph"
|
||||||
|
|
|
@ -503,11 +503,30 @@
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
<com.jjoe64.graphview.GraphView
|
<com.jjoe64.graphview.GraphView
|
||||||
android:id="@+id/overview_bggraph"
|
android:id="@+id/overview_bggraph"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="0dp"
|
android:layout_height="160dip"
|
||||||
android:layout_weight="1" />
|
android:layout_alignParentStart="true"
|
||||||
|
android:layout_alignParentTop="true" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/overview_updating"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
|
android:layout_centerInParent="true"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:text="@string/updating"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||||
|
android:textColor="@color/updating"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
<com.jjoe64.graphview.GraphView
|
<com.jjoe64.graphview.GraphView
|
||||||
android:id="@+id/overview_iobgraph"
|
android:id="@+id/overview_iobgraph"
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
<color name="tabBgColor">#f0003f59</color>
|
<color name="tabBgColor">#f0003f59</color>
|
||||||
<color name="tabBgColorSelected">#FF33B5E5</color>
|
<color name="tabBgColorSelected">#FF33B5E5</color>
|
||||||
<color name="deviations">#FF0000</color>
|
<color name="deviations">#FF0000</color>
|
||||||
|
<color name="updating">#50ffffff</color>
|
||||||
|
|
||||||
<color name="defaultbackground">#424242</color>
|
<color name="defaultbackground">#424242</color>
|
||||||
|
|
||||||
|
|
|
@ -625,4 +625,5 @@
|
||||||
<string name="invalidprofile">Invalid profile !!!</string>
|
<string name="invalidprofile">Invalid profile !!!</string>
|
||||||
<string name="profileswitch">ProfileSwitch</string>
|
<string name="profileswitch">ProfileSwitch</string>
|
||||||
<string name="careportal_pbage_label">Pump battery age</string>
|
<string name="careportal_pbage_label">Pump battery age</string>
|
||||||
|
<string name="updating">Updating ...</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Reference in a new issue