From 96427cf3dcebd261084088f266dd40e62e2db239 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Thu, 9 Mar 2017 10:59:11 +0100 Subject: [PATCH] use onAttach for context in CalibrationDialog --- .../plugins/Overview/Dialogs/CalibrationDialog.java | 10 ++++++---- .../androidaps/plugins/Overview/OverviewFragment.java | 1 - 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/CalibrationDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/CalibrationDialog.java index 5c96cb58e5..d9ab1aa312 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/CalibrationDialog.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/CalibrationDialog.java @@ -35,14 +35,16 @@ public class CalibrationDialog extends DialogFragment implements View.OnClickLis PlusMinusEditText bgText; TextView unitsView; - Context parentContext; + Context context; public CalibrationDialog() { // Required empty public constructor } - public void setContext(Context context) { - parentContext = context; + @Override + public void onAttach(Context context) { + super.onAttach(context); + this.context = context; } @Override @@ -74,7 +76,7 @@ public class CalibrationDialog extends DialogFragment implements View.OnClickLis switch (view.getId()) { case R.id.overview_calibration_okbutton: final Double bg = bgText.getValue(); - XdripCalibrations.confirmAndSendCalibration(bg, parentContext); + XdripCalibrations.confirmAndSendCalibration(bg, context); dismiss(); Answers.getInstance().logCustom(new CustomEvent("Calibration")); break; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java index a51d3c5ff1..d24739c9cf 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java @@ -249,7 +249,6 @@ public class OverviewFragment extends Fragment { public void onClick(View view) { FragmentManager manager = getFragmentManager(); CalibrationDialog calibrationDialog = new CalibrationDialog(); - calibrationDialog.setContext(getContext()); calibrationDialog.show(manager, "CalibrationDialog"); } });