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

Commit 03887a9b authored by Siarhei Vishniakou's avatar Siarhei Vishniakou Committed by android-build-merger
Browse files

Merge "Add a null check for getWindow()" am: 3c69948e am: 71f52a6a

am: bee3e01c

Change-Id: Iee9698396354eb0e0cacff759cc0dcef621ff514
parents f4df3d95 bee3e01c
Loading
Loading
Loading
Loading
+20 −5
Original line number Diff line number Diff line
@@ -349,16 +349,31 @@ public abstract class DialogPreference extends Preference implements
        dialog.show();
    }

    /**
     * Get the DecorView.
     * @return the DecorView for the current dialog window, if it exists.
     * If the window does not exist, null is returned.
     */
    private View getDecorView() {
        if (mDialog != null && mDialog.getWindow() != null) {
            return mDialog.getWindow().getDecorView();
        }
        return null;
    }

    void postDismiss() {
        removeDismissCallbacks();
        View decorView = mDialog.getWindow().getDecorView();
        View decorView = getDecorView();
        if (decorView != null) {
            // If decorView is null, dialog was already dismissed
            decorView.post(mDismissRunnable);
        }
    }

    private void removeDismissCallbacks() {
        if (mDialog != null && mDialog.getWindow() != null
                && mDialog.getWindow().getDecorView() != null) {
            mDialog.getWindow().getDecorView().removeCallbacks(mDismissRunnable);
        View decorView = getDecorView();
        if (decorView != null) {
            decorView.removeCallbacks(mDismissRunnable);
        }
    }