Save & restore dialog state on screen rotate
This commit is contained in:
parent
b689aff02d
commit
cd4e7c2d4f
|
@ -148,6 +148,11 @@ public class NewInsulinDialog extends DialogFragment implements OnClickListener
|
|||
|
||||
setCancelable(true);
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -156,6 +161,18 @@ public class NewInsulinDialog extends DialogFragment implements OnClickListener
|
|||
return value > 0 ? "+" + formatted : formatted;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(Bundle insulinDialogState) {
|
||||
insulinDialogState.putString("message", "This is my message to be reloaded");
|
||||
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
|
||||
public synchronized void onClick(View view) {
|
||||
switch (view.getId()) {
|
||||
|
|
Loading…
Reference in a new issue