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

Commit 0dadf4d0 authored by Alan Viverette's avatar Alan Viverette Committed by Android (Google) Code Review
Browse files

Merge "Replace auto-create in findViewById() with explicit create() API"

parents f3537421 f34ef74e
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -3393,6 +3393,7 @@ package android.app {
    method public void addContentView(android.view.View, android.view.ViewGroup.LayoutParams);
    method public void cancel();
    method public void closeOptionsMenu();
    method public void create();
    method public void dismiss();
    method public boolean dispatchGenericMotionEvent(android.view.MotionEvent);
    method public boolean dispatchKeyEvent(android.view.KeyEvent);
+2 −8
Original line number Diff line number Diff line
@@ -147,12 +147,8 @@ public class AlertDialog extends Dialog implements DialogInterface {

    /**
     * Gets one of the buttons used in the dialog. Returns null if the specified
     * button does not exist in the dialog.
     * <p>
     * Prior to API 20, this function could only be called after the dialog was
     * shown. In later versions, this function may be called at any time;
     * however, calling this function locks in various attributes including
     * buttons and icons.
     * button does not exist or the dialog has not yet been fully created (for
     * example, via {@link #show()} or {@link #create()}).
     *
     * @param whichButton The identifier of the button that should be returned.
     *            For example, this can be
@@ -160,8 +156,6 @@ public class AlertDialog extends Dialog implements DialogInterface {
     * @return The button from the dialog, or null if a button does not exist.
     */
    public Button getButton(int whichButton) {
        // Superclass handles re-entrance and multiple calls.
        dispatchOnCreate(null);
        return mAlert.getButton(whichButton);
    }

+16 −15
Original line number Diff line number Diff line
@@ -105,9 +105,6 @@ public class Dialog implements DialogInterface, Window.Callback,
    private boolean mShowing = false;
    private boolean mCanceled = false;

    /** Whether the execution path is currently in onCreate(). */
    private boolean mInOnCreate = false;

    private final Handler mHandler = new Handler();

    private static final int DISMISS = 0x43;
@@ -241,6 +238,18 @@ public class Dialog implements DialogInterface, Window.Callback,
        return mShowing;
    }

    /**
     * Forces immediate creation of the dialog.
     * <p>
     * Note that you should not override this method to perform dialog creation.
     * Rather, override {@link #onCreate(Bundle)}.
     */
    public void create() {
        if (!mCreated) {
            dispatchOnCreate(null);
        }
    }

    /**
     * Start the dialog and display it on screen.  The window is placed in the
     * application layer and opaque.  Note that you should not override this
@@ -359,10 +368,8 @@ 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 && !mInOnCreate) {
            mInOnCreate = true;
        if (!mCreated) {
            onCreate(savedInstanceState);
            mInOnCreate = false;
            mCreated = true;
        }
    }
@@ -461,20 +468,14 @@ public class Dialog implements DialogInterface, Window.Callback,
    }

    /**
     * Finds a child view with the given identifier.
     * <p>
     * Prior to API 20, this function could only be used after the first call
     * to {@link #show()}. In later versions, this function may be used at any
     * time; however, the first call to this function "locks in" certain dialog
     * characteristics.
     * Finds a child view with the given identifier. Returns null if the
     * specified child view does not exist or the dialog has not yet been fully
     * created (for example, via {@link #show()} or {@link #create()}).
     *
     * @param id the identifier of the view to find
     * @return The view with the given id or null.
     */
    public View findViewById(int id) {
        if (!mCreated) {
            dispatchOnCreate(null);
        }
        return mWindow.findViewById(id);
    }