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;
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;

View file

@ -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");
}
});