From 50145bc883909c4b1533894a2b947eed21312514 Mon Sep 17 00:00:00 2001 From: Bjorn Bringert <bringert@android.com> Date: Thu, 11 Jun 2009 12:30:48 +0100 Subject: ACTV: getWindowVisibility() instead of private attach count When debugging a problem with the search dialog drop-down sometimes not showing up, I saw that the mAttachCount variable in AutoCompleteTextView could get a negative value because onDetachedFromWindow() was called multiple times. This lead to the drop-down not being displayed on filtering. Instead of the private attach count in ACTV, this change uses View.getWindowVisibility(). --- core/java/android/widget/AutoCompleteTextView.java | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'core/java/android/widget/AutoCompleteTextView.java') diff --git a/core/java/android/widget/AutoCompleteTextView.java b/core/java/android/widget/AutoCompleteTextView.java index f376ce5..585ce3d 100644 --- a/core/java/android/widget/AutoCompleteTextView.java +++ b/core/java/android/widget/AutoCompleteTextView.java @@ -123,10 +123,6 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe private AutoCompleteTextView.ListSelectorHider mHideSelector; - // Indicates whether this AutoCompleteTextView is attached to a window or not - // The widget is attached to a window when mAttachCount > 0 - private int mAttachCount; - private AutoCompleteTextView.PassThroughClickListener mPassThroughClickListener; public AutoCompleteTextView(Context context) { @@ -960,7 +956,8 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe /** {@inheritDoc} */ public void onFilterComplete(int count) { - if (mAttachCount <= 0) return; + // Not attached to window, don't update drop-down + if (getWindowVisibility() == View.GONE) return; /* * This checks enoughToFilter() again because filtering requests @@ -999,13 +996,11 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe @Override protected void onAttachedToWindow() { super.onAttachedToWindow(); - mAttachCount++; } @Override protected void onDetachedFromWindow() { dismissDropDown(); - mAttachCount--; super.onDetachedFromWindow(); } -- cgit v1.1