Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3b40ebfa authored by Romain Guy's avatar Romain Guy Committed by Android (Google) Code Review
Browse files

Merge "Fix NPE in AutoCompleteTextView to tame the monkeys. Bug #2522599"

parents 75d20e93 11d5bfde
Loading
Loading
Loading
Loading
+14 −8
Original line number Diff line number Diff line
@@ -660,13 +660,19 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe

                final boolean below = !mPopup.isAboveAnchor();

                final ListAdapter adapter = mDropDownList.getAdapter();
                final boolean allEnabled = adapter.areAllItemsEnabled();
                final ListAdapter adapter = mAdapter;
                
                boolean allEnabled;
                int firstItem = Integer.MAX_VALUE;
                int lastItem = Integer.MIN_VALUE;

                final int firstItem = allEnabled ? 0 :
                if (adapter != null) {
                    allEnabled = adapter.areAllItemsEnabled();
                    firstItem = allEnabled ? 0 :
                            mDropDownList.lookForSelectablePosition(0, true);
                final int lastItem = allEnabled ? adapter.getCount() - 1 :
                    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)) {