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

Commit 11d5bfde authored by Romain Guy's avatar Romain Guy
Browse files

Fix NPE in AutoCompleteTextView to tame the monkeys.

Bug #2522599

Change-Id: I85654898399e5329585fb6aa5f3890ca4c22e2bf
parent 4f43ae09
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)) {