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

Commit 114405e0 authored by Dianne Hackborn's avatar Dianne Hackborn
Browse files

Fix Dialog generating multiple onCancel().

Issue #3169193: com.google.android.youtube: java.lang.NullPointerException
at com.google.android.youtube.async.UserAuthorizer$3.onCancel(UserAuthorizer.java:324)

A little protection against calling onCancel() after a dialog has been
dismissed.

Change-Id: I7a64c94703da012ce303308563e4a8ed3cb125d3
parent f2e69a91
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -91,7 +91,8 @@ public class AlertDialog extends Dialog implements DialogInterface {
            final float x = ev.getX();
            final float y = ev.getY();

            if (mCancelable && (x < 0 || x > width || y < 0 || y > height)) {
            if (mCancelable && (x < 0 || x > width || y < 0 || y > height)
                    &&  mDecor != null && isShowing()) {
                cancel();
                return true;
            }
+1 −2
Original line number Diff line number Diff line
@@ -582,7 +582,7 @@ public class Dialog implements DialogInterface, Window.Callback,
     */
    public boolean onTouchEvent(MotionEvent event) {
        if (mCancelable && mCanceledOnTouchOutside && event.getAction() == MotionEvent.ACTION_DOWN
                && isOutOfBounds(event)) {
                && isOutOfBounds(event) && mDecor != null && mShowing) {
            cancel();
            return true;
        }
@@ -998,7 +998,6 @@ public class Dialog implements DialogInterface, Window.Callback,
     */
    public void cancel() {
        if (mCancelMessage != null) {
            
            // Obtain a new message so this dialog can be re-used
            Message.obtain(mCancelMessage).sendToTarget();
        }