Merge pull request #1224 from PoweRGbg/patch-2

Save & restore dialog state on screen rotate
This commit is contained in:
Milos Kozak 2018-07-17 19:17:05 +03:00 committed by GitHub
commit 50a5e70051
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -148,6 +148,11 @@ public class NewInsulinDialog extends DialogFragment implements OnClickListener
setCancelable(true); setCancelable(true);
getDialog().setCanceledOnTouchOutside(false); getDialog().setCanceledOnTouchOutside(false);
if (savedInstanceState != null) {
// log.debug("savedInstanceState in onCreate is:" + savedInstanceState.toString());
editInsulin.setValue(savedInstanceState.getDouble("editInsulin"));
editTime.setValue(savedInstanceState.getDouble("editTime"));
}
return view; return view;
} }
@ -156,6 +161,17 @@ public class NewInsulinDialog extends DialogFragment implements OnClickListener
return value > 0 ? "+" + formatted : formatted; return value > 0 ? "+" + formatted : formatted;
} }
@Override
public void onSaveInstanceState(Bundle insulinDialogState) {
insulinDialogState.putBoolean("startEatingSoonTTCheckbox", startEatingSoonTTCheckbox.isChecked());
insulinDialogState.putBoolean("recordOnlyCheckbox", recordOnlyCheckbox.isChecked());
insulinDialogState.putDouble("editTime", editTime.getValue());
insulinDialogState.putDouble("editInsulin", editInsulin.getValue());
insulinDialogState.putString("notesEdit",notesEdit.getText().toString());
log.debug("Instance state saved:"+insulinDialogState.toString());
super.onSaveInstanceState(insulinDialogState);
}
@Override @Override
public synchronized void onClick(View view) { public synchronized void onClick(View view) {
switch (view.getId()) { switch (view.getId()) {