Merge pull request #1224 from PoweRGbg/patch-2
Save & restore dialog state on screen rotate
This commit is contained in:
commit
50a5e70051
1 changed files with 16 additions and 0 deletions
|
@ -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()) {
|
||||||
|
|
Loading…
Reference in a new issue