use onAttach for context in CalibrationDialog

This commit is contained in:
Milos Kozak 2017-03-09 10:59:11 +01:00
parent 7c6d708d06
commit 96427cf3dc
2 changed files with 6 additions and 5 deletions

View file

@ -35,14 +35,16 @@ public class CalibrationDialog extends DialogFragment implements View.OnClickLis
PlusMinusEditText bgText; PlusMinusEditText bgText;
TextView unitsView; TextView unitsView;
Context parentContext; Context context;
public CalibrationDialog() { public CalibrationDialog() {
// Required empty public constructor // Required empty public constructor
} }
public void setContext(Context context) { @Override
parentContext = context; public void onAttach(Context context) {
super.onAttach(context);
this.context = context;
} }
@Override @Override
@ -74,7 +76,7 @@ public class CalibrationDialog extends DialogFragment implements View.OnClickLis
switch (view.getId()) { switch (view.getId()) {
case R.id.overview_calibration_okbutton: case R.id.overview_calibration_okbutton:
final Double bg = bgText.getValue(); final Double bg = bgText.getValue();
XdripCalibrations.confirmAndSendCalibration(bg, parentContext); XdripCalibrations.confirmAndSendCalibration(bg, context);
dismiss(); dismiss();
Answers.getInstance().logCustom(new CustomEvent("Calibration")); Answers.getInstance().logCustom(new CustomEvent("Calibration"));
break; break;

View file

@ -249,7 +249,6 @@ public class OverviewFragment extends Fragment {
public void onClick(View view) { public void onClick(View view) {
FragmentManager manager = getFragmentManager(); FragmentManager manager = getFragmentManager();
CalibrationDialog calibrationDialog = new CalibrationDialog(); CalibrationDialog calibrationDialog = new CalibrationDialog();
calibrationDialog.setContext(getContext());
calibrationDialog.show(manager, "CalibrationDialog"); calibrationDialog.show(manager, "CalibrationDialog");
} }
}); });