Fixes #1933428. Call onPrepareDialog() on managed dialogs after their onCreate() is finished.
This commit is contained in:
@ -857,7 +857,7 @@ public class Activity extends ContextThemeWrapper
|
||||
if (dialogState != null) {
|
||||
// Calling onRestoreInstanceState() below will invoke dispatchOnCreate
|
||||
// so tell createDialog() not to do it, otherwise we get an exception
|
||||
final Dialog dialog = createDialog(dialogId, false);
|
||||
final Dialog dialog = createDialog(dialogId, dialogState);
|
||||
mManagedDialogs.put(dialogId, dialog);
|
||||
onPrepareDialog(dialogId, dialog);
|
||||
dialog.onRestoreInstanceState(dialogState);
|
||||
@ -865,13 +865,13 @@ public class Activity extends ContextThemeWrapper
|
||||
}
|
||||
}
|
||||
|
||||
private Dialog createDialog(Integer dialogId, boolean dispatchOnCreate) {
|
||||
private Dialog createDialog(Integer dialogId, Bundle state) {
|
||||
final Dialog dialog = onCreateDialog(dialogId);
|
||||
if (dialog == null) {
|
||||
throw new IllegalArgumentException("Activity#onCreateDialog did "
|
||||
+ "not create a dialog for id " + dialogId);
|
||||
}
|
||||
if (dispatchOnCreate) dialog.dispatchOnCreate(null);
|
||||
dialog.dispatchOnCreate(state);
|
||||
return dialog;
|
||||
}
|
||||
|
||||
@ -2407,7 +2407,7 @@ public class Activity extends ContextThemeWrapper
|
||||
}
|
||||
Dialog dialog = mManagedDialogs.get(id);
|
||||
if (dialog == null) {
|
||||
dialog = createDialog(id, true);
|
||||
dialog = createDialog(id, null);
|
||||
mManagedDialogs.put(id, dialog);
|
||||
}
|
||||
|
||||
|
@ -292,9 +292,11 @@ public class Dialog implements DialogInterface, Window.Callback,
|
||||
// internal method to make sure mcreated is set properly without requiring
|
||||
// users to call through to super in onCreate
|
||||
void dispatchOnCreate(Bundle savedInstanceState) {
|
||||
if (!mCreated) {
|
||||
onCreate(savedInstanceState);
|
||||
mCreated = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Similar to {@link Activity#onCreate}, you should initialized your dialog
|
||||
|
Reference in New Issue
Block a user