safer display values in openapsma fragment

This commit is contained in:
Milos Kozak 2017-01-03 10:24:08 +01:00
parent 54278dd794
commit fe75298263

View file

@ -17,6 +17,7 @@ import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.interfaces.FragmentBase; import info.nightscout.androidaps.interfaces.FragmentBase;
import info.nightscout.androidaps.plugins.Loop.APSResult;
import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSMAUpdateGui; import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSMAUpdateGui;
import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSMAUpdateResultGui; import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSMAUpdateResultGui;
import info.nightscout.utils.JSONFormatter; import info.nightscout.utils.JSONFormatter;
@ -101,14 +102,20 @@ public class OpenAPSMAFragment extends Fragment implements View.OnClickListener,
activity.runOnUiThread(new Runnable() { activity.runOnUiThread(new Runnable() {
@Override @Override
public void run() { public void run() {
if (getPlugin().lastAPSResult != null) { DetermineBasalResult lastAPSResult = getPlugin().lastAPSResult;
glucoseStatusView.setText(JSONFormatter.format(getPlugin().lastDetermineBasalAdapterJS.getGlucoseStatusParam())); if (lastAPSResult != null) {
currentTempView.setText(JSONFormatter.format(getPlugin().lastDetermineBasalAdapterJS.getCurrentTempParam())); resultView.setText(JSONFormatter.format(lastAPSResult.json));
iobDataView.setText(JSONFormatter.format(getPlugin().lastDetermineBasalAdapterJS.getIobDataParam())); requestView.setText(lastAPSResult.toSpanned());
profileView.setText(JSONFormatter.format(getPlugin().lastDetermineBasalAdapterJS.getProfileParam())); }
mealDataView.setText(JSONFormatter.format(getPlugin().lastDetermineBasalAdapterJS.getMealDataParam())); DetermineBasalAdapterJS determineBasalAdapterJS = getPlugin().lastDetermineBasalAdapterJS;
resultView.setText(JSONFormatter.format(getPlugin().lastAPSResult.json)); if (determineBasalAdapterJS != null) {
requestView.setText(getPlugin().lastAPSResult.toSpanned()); glucoseStatusView.setText(JSONFormatter.format(determineBasalAdapterJS.getGlucoseStatusParam()));
currentTempView.setText(JSONFormatter.format(determineBasalAdapterJS.getCurrentTempParam()));
iobDataView.setText(JSONFormatter.format(determineBasalAdapterJS.getIobDataParam()));
profileView.setText(JSONFormatter.format(determineBasalAdapterJS.getProfileParam()));
mealDataView.setText(JSONFormatter.format(determineBasalAdapterJS.getMealDataParam()));
}
if (getPlugin().lastAPSRun != null) {
lastRunView.setText(getPlugin().lastAPSRun.toLocaleString()); lastRunView.setText(getPlugin().lastAPSRun.toLocaleString());
} }
} }