Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6de4aed1 authored by Romain Guy's avatar Romain Guy
Browse files

Fixes #1933428. Call onPrepareDialog() on managed dialogs after their onCreate() is finished.

parent 1bd3e0fb
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -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);
        }
        
+4 −2
Original line number Diff line number Diff line
@@ -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