diff options
Diffstat (limited to 'core/java/android/app')
-rw-r--r-- | core/java/android/app/SearchDialog.java | 27 |
1 files changed, 8 insertions, 19 deletions
diff --git a/core/java/android/app/SearchDialog.java b/core/java/android/app/SearchDialog.java index 15e0a4d..64288d2 100644 --- a/core/java/android/app/SearchDialog.java +++ b/core/java/android/app/SearchDialog.java @@ -126,14 +126,6 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS // support for AutoCompleteTextView suggestions display private SuggestionsAdapter mSuggestionsAdapter; - private Handler mHandler = new Handler(); - private Runnable mInstallSuggestionAdapter = new Runnable() { - public void run() { - if (mSearchTextField != null) { - mSearchTextField.setAdapter(mSuggestionsAdapter); - } - } - }; /** * Constructor - fires it up and makes it look like the search UI. @@ -261,8 +253,8 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS mSearchTextField.setAdapter(mSuggestionsAdapter); mSearchTextField.setText(initialQuery); } else { - mSuggestionsAdapter = new SuggestionsAdapter(getContext(), mSearchable, - mHandler, mInstallSuggestionAdapter); + mSuggestionsAdapter = new SuggestionsAdapter(getContext(), mSearchable, + mSearchTextField); mSearchTextField.setAdapter(mSuggestionsAdapter); // finally, load the user's initial text (which may trigger suggestions) @@ -1305,15 +1297,13 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS // These private variables are shared by the filter thread and must be protected private WeakReference<Cursor> mRecentCursor = new WeakReference<Cursor>(null); private boolean mNonUserQuery = false; - private Handler mHandler; - private Runnable mInstallSuggestionAdapter; + private AutoCompleteTextView mParentView; public SuggestionsAdapter(Context context, SearchableInfo searchable, - Handler handler, Runnable installSuggestionAdapter) { + AutoCompleteTextView actv) { super(context, -1, null, null, null); mSearchable = searchable; - mHandler = handler; - mInstallSuggestionAdapter = installSuggestionAdapter; + mParentView = actv; // set up provider resources (gives us icons, etc.) Context activityContext = mSearchable.getActivityContext(mContext); @@ -1426,13 +1416,12 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS to = ONE_LINE_TO; } } + // Force the underlying ListView to discard and reload all layouts + // (Note, this should be optimized for cases where layout/cursor remain same) + mParentView.resetListAndClearViews(); // Now actually set up the cursor, columns, and the list view changeCursorAndColumns(c, from, to); setViewResource(layout); - // Force the underlying ListView to discard and reload all layouts - // (Note, this could be optimized for cases where layout/cursor remain same) - mHandler.post(mInstallSuggestionAdapter); - } else { // Provide some help for developers instead of just silently discarding Log.w(LOG_TAG, "Suggestions cursor discarded due to missing required columns."); |