1616
1717package android .widget ;
1818
19- import com .android .internal .R ;
20-
2119import android .content .Context ;
2220import android .content .res .TypedArray ;
2321import android .database .DataSetObserver ;
3836import android .view .inputmethod .EditorInfo ;
3937import android .view .inputmethod .InputMethodManager ;
4038
39+ import com .android .internal .R ;
40+
4141
4242/**
4343 * <p>An editable text view that shows completion suggestions automatically
@@ -744,7 +744,6 @@ void doAfterTextChanged() {
744744 if (mFilter != null ) {
745745 mPopupCanBeUpdated = true ;
746746 performFiltering (getText (), mLastKeyCode );
747- buildImeCompletions ();
748747 }
749748 } else {
750749 // drop down is automatically dismissed when enough characters
@@ -837,10 +836,6 @@ public void performCompletion() {
837836 @ Override
838837 public void onCommitCompletion (CompletionInfo completion ) {
839838 if (isPopupShowing ()) {
840- mBlockCompletion = true ;
841- replaceText (completion .getText ());
842- mBlockCompletion = false ;
843-
844839 mPopup .performItemClick (completion .getPosition ());
845840 }
846841 }
@@ -938,7 +933,8 @@ private void updateDropDownForFilter(int count) {
938933 */
939934
940935 final boolean dropDownAlwaysVisible = mPopup .isDropDownAlwaysVisible ();
941- if ((count > 0 || dropDownAlwaysVisible ) && enoughToFilter ()) {
936+ final boolean enoughToFilter = enoughToFilter ();
937+ if ((count > 0 || dropDownAlwaysVisible ) && enoughToFilter ) {
942938 if (hasFocus () && hasWindowFocus () && mPopupCanBeUpdated ) {
943939 showDropDown ();
944940 }
@@ -1049,6 +1045,8 @@ public boolean isInputMethodNotNeeded() {
10491045 * <p>Displays the drop down on screen.</p>
10501046 */
10511047 public void showDropDown () {
1048+ buildImeCompletions ();
1049+
10521050 if (mPopup .getAnchorView () == null ) {
10531051 if (mDropDownAnchorId != View .NO_ID ) {
10541052 mPopup .setAnchorView (getRootView ().findViewById (mDropDownAnchorId ));
@@ -1064,7 +1062,7 @@ public void showDropDown() {
10641062 mPopup .show ();
10651063 mPopup .getListView ().setOverScrollMode (View .OVER_SCROLL_ALWAYS );
10661064 }
1067-
1065+
10681066 /**
10691067 * Forces outside touches to be ignored. Normally if {@link #isDropDownAlwaysVisible()} is
10701068 * false, we allow outside touch to dismiss the dropdown. If this is set to true, then we
@@ -1075,7 +1073,7 @@ public void showDropDown() {
10751073 public void setForceIgnoreOutsideTouch (boolean forceIgnoreOutsideTouch ) {
10761074 mPopup .setForceIgnoreOutsideTouch (forceIgnoreOutsideTouch );
10771075 }
1078-
1076+
10791077 private void buildImeCompletions () {
10801078 final ListAdapter adapter = mAdapter ;
10811079 if (adapter != null ) {
@@ -1090,8 +1088,7 @@ private void buildImeCompletions() {
10901088 realCount ++;
10911089 Object item = adapter .getItem (i );
10921090 long id = adapter .getItemId (i );
1093- completions [i ] = new CompletionInfo (id , i ,
1094- convertSelectionToString (item ));
1091+ completions [i ] = new CompletionInfo (id , i , convertSelectionToString (item ));
10951092 }
10961093 }
10971094
0 commit comments