diff options
| author | Romain Guy <romainguy@android.com> | 2009-09-30 11:36:01 -0700 |
|---|---|---|
| committer | Romain Guy <romainguy@android.com> | 2009-09-30 11:55:58 -0700 |
| commit | aa1c6311d6d900261bcd9f3b0986b6c0394af07a (patch) | |
| tree | ebda9c0ec287cc81e9e365de99be11425d93d831 /core/java/android/widget/AutoCompleteTextView.java | |
| parent | 86aece8b4ad6d55cc9a3c185c3730d7387a46661 (diff) | |
Fix possible crash in AutoCompleteTextView.
This change makes sure that ACTV will not take action when an event is
received in a popup that just got dismissed.
This change also makes public two XML attributes of ACTV whose corresponding
Java APIs are public.
This change also fixes a couple of typos.
Change-Id: I78f113bc522d199ff3db44fc4cc3a1882afe822e
Diffstat (limited to 'core/java/android/widget/AutoCompleteTextView.java')
| -rw-r--r-- | core/java/android/widget/AutoCompleteTextView.java | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/core/java/android/widget/AutoCompleteTextView.java b/core/java/android/widget/AutoCompleteTextView.java index 953dd92dae41..1449ea550504 100644 --- a/core/java/android/widget/AutoCompleteTextView.java +++ b/core/java/android/widget/AutoCompleteTextView.java @@ -82,6 +82,8 @@ import com.android.internal.R; * @attr ref android.R.styleable#AutoCompleteTextView_dropDownAnchor * @attr ref android.R.styleable#AutoCompleteTextView_dropDownWidth * @attr ref android.R.styleable#AutoCompleteTextView_dropDownHeight + * @attr ref android.R.styleable#AutoCompleteTextView_dropDownVerticalOffset + * @attr ref android.R.styleable#AutoCompleteTextView_dropDownHorizontalOffset */ public class AutoCompleteTextView extends EditText implements Filter.FilterListener { static final boolean DEBUG = false; @@ -1153,7 +1155,7 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe heightSpec = mDropDownHeight; } - mPopup.setOutsideTouchable(mForceIgnoreOutsideTouch ? false : !mDropDownAlwaysVisible); + mPopup.setOutsideTouchable(!mForceIgnoreOutsideTouch && !mDropDownAlwaysVisible); mPopup.update(getDropDownAnchorView(), mDropDownHorizontalOffset, mDropDownVerticalOffset, widthSpec, heightSpec); @@ -1183,8 +1185,8 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe // use outside touchable to dismiss drop down when touching outside of it, so // only set this if the dropdown is not always visible - mPopup.setOutsideTouchable(mForceIgnoreOutsideTouch ? false : !mDropDownAlwaysVisible); - mPopup.setTouchInterceptor(new PopupTouchIntercepter()); + mPopup.setOutsideTouchable(!mForceIgnoreOutsideTouch && !mDropDownAlwaysVisible); + mPopup.setTouchInterceptor(new PopupTouchInterceptor()); mPopup.showAsDropDown(getDropDownAnchorView(), mDropDownHorizontalOffset, mDropDownVerticalOffset); mDropDownList.setSelection(ListView.INVALID_POSITION); @@ -1408,9 +1410,10 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe } } - private class PopupTouchIntercepter implements OnTouchListener { + private class PopupTouchInterceptor implements OnTouchListener { public boolean onTouch(View v, MotionEvent event) { - if (event.getAction() == MotionEvent.ACTION_DOWN) { + if (event.getAction() == MotionEvent.ACTION_DOWN && + mPopup != null && mPopup.isShowing()) { mPopup.setInputMethodMode(PopupWindow.INPUT_METHOD_NOT_NEEDED); showDropDown(); } |
