From c8bfc68cddc15787943e7db1ba1cfeb26d4f74d3 Mon Sep 17 00:00:00 2001 From: Alan Viverette Date: Thu, 7 May 2015 13:00:25 -0700 Subject: [PATCH] Only resize list popup if it's still attached to a window We can't rely on ListPopupWindow.dismiss() to get called before the popup is removed, for example when the activity hosting the popup is finished, but we can easily ensure that the popup is still attached to a window. Bug: 20831507 Change-Id: I9dcaa46e68df3f2b301cf299fa64d460c7e177fd --- core/java/android/widget/ListPopupWindow.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/java/android/widget/ListPopupWindow.java b/core/java/android/widget/ListPopupWindow.java index 05866f07f9a9b..94b9416bfdada 100644 --- a/core/java/android/widget/ListPopupWindow.java +++ b/core/java/android/widget/ListPopupWindow.java @@ -1791,8 +1791,9 @@ public class ListPopupWindow { private class ResizePopupRunnable implements Runnable { public void run() { - if (mDropDownList != null && mDropDownList.getCount() > mDropDownList.getChildCount() && - mDropDownList.getChildCount() <= mListItemExpandMaximum) { + if (mDropDownList != null && mDropDownList.isAttachedToWindow() + && mDropDownList.getCount() > mDropDownList.getChildCount() + && mDropDownList.getChildCount() <= mListItemExpandMaximum) { mPopup.setInputMethodMode(PopupWindow.INPUT_METHOD_NOT_NEEDED); show(); }