diff options
| author | 2015-03-02 12:40:34 -0800 | |
|---|---|---|
| committer | 2015-03-02 12:40:34 -0800 | |
| commit | df4639a0135ea643b493067b3f7cd1e092346c78 (patch) | |
| tree | 6cfba6bc622165415756124befc978cca9f2dcc9 | |
| parent | 228fd600cebe51e612357489310bc239d6bf24cc (diff) | |
Improve handling of activity destroy during popup exit animation
Ensures the decor view isn't double-removed and that we don't try to
dereference a null anchor view.
Bug: 19553353
Bug: 19551371
Change-Id: I191a41f9065b68e49d66f96794cb7456f79d2d34
| -rw-r--r-- | core/java/android/widget/PopupWindow.java | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/core/java/android/widget/PopupWindow.java b/core/java/android/widget/PopupWindow.java index a929f3dfd5a0..399f4c5a65ca 100644 --- a/core/java/android/widget/PopupWindow.java +++ b/core/java/android/widget/PopupWindow.java @@ -160,14 +160,14 @@ public class PopupWindow { private final EpicenterCallback mEpicenterCallback = new EpicenterCallback() { @Override public Rect onGetEpicenter(Transition transition) { - final View anchor = mAnchor.get(); + final View anchor = mAnchor != null ? mAnchor.get() : null; final View decor = mDecorView; if (anchor == null || decor == null) { return null; } final Rect anchorBounds = mAnchorBounds; - final int[] anchorLocation = mAnchor.get().getLocationOnScreen(); + final int[] anchorLocation = anchor.getLocationOnScreen(); final int[] popupLocation = mDecorView.getLocationOnScreen(); // Compute the position of the anchor relative to the popup. @@ -1632,8 +1632,14 @@ public class PopupWindow { * view hierarchy, if necessary. */ private void dismissImmediate(View contentView) { + if (mDecorView == null || mBackgroundView == null) { + throw new RuntimeException("Popup window already dismissed"); + } + try { - mWindowManager.removeViewImmediate(mDecorView); + if (mDecorView.isAttachedToWindow()) { + mWindowManager.removeViewImmediate(mDecorView); + } } finally { mDecorView.removeView(mBackgroundView); mDecorView = null; |