summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRomain Guy <romainguy@android.com>2010-03-17 11:08:17 -0700
committerRomain Guy <romainguy@android.com>2010-03-17 11:08:17 -0700
commit11d5bfde8488505e15aa83275772d84579de04ca (patch)
treeb74deaba4c0520330f0ca503ca09459c2a5a162c
parent4f43ae09d2cb0cce2b9e794f1b80f7198333c94b (diff)
downloadframeworks_base-11d5bfde8488505e15aa83275772d84579de04ca.zip
frameworks_base-11d5bfde8488505e15aa83275772d84579de04ca.tar.gz
frameworks_base-11d5bfde8488505e15aa83275772d84579de04ca.tar.bz2
Fix NPE in AutoCompleteTextView to tame the monkeys.
Bug #2522599 Change-Id: I85654898399e5329585fb6aa5f3890ca4c22e2bf
-rw-r--r--core/java/android/widget/AutoCompleteTextView.java22
1 files changed, 14 insertions, 8 deletions
diff --git a/core/java/android/widget/AutoCompleteTextView.java b/core/java/android/widget/AutoCompleteTextView.java
index 5482958..5b52107 100644
--- a/core/java/android/widget/AutoCompleteTextView.java
+++ b/core/java/android/widget/AutoCompleteTextView.java
@@ -660,14 +660,20 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe
final boolean below = !mPopup.isAboveAnchor();
- final ListAdapter adapter = mDropDownList.getAdapter();
- final boolean allEnabled = adapter.areAllItemsEnabled();
-
- final int firstItem = allEnabled ? 0 :
- mDropDownList.lookForSelectablePosition(0, true);
- final int lastItem = allEnabled ? adapter.getCount() - 1 :
- mDropDownList.lookForSelectablePosition(adapter.getCount() - 1, false);
-
+ final ListAdapter adapter = mAdapter;
+
+ boolean allEnabled;
+ int firstItem = Integer.MAX_VALUE;
+ int lastItem = Integer.MIN_VALUE;
+
+ if (adapter != null) {
+ allEnabled = adapter.areAllItemsEnabled();
+ firstItem = allEnabled ? 0 :
+ mDropDownList.lookForSelectablePosition(0, true);
+ lastItem = allEnabled ? adapter.getCount() - 1 :
+ mDropDownList.lookForSelectablePosition(adapter.getCount() - 1, false);
+ }
+
if ((below && keyCode == KeyEvent.KEYCODE_DPAD_UP && curIndex <= firstItem) ||
(!below && keyCode == KeyEvent.KEYCODE_DPAD_DOWN && curIndex >= lastItem)) {
// When the selection is at the top, we block the key