diff options
author | Satish Sampath <satish@android.com> | 2009-07-01 17:48:42 +0100 |
---|---|---|
committer | Satish Sampath <satish@android.com> | 2009-07-01 17:55:31 +0100 |
commit | fef8d3e4d8f6f46c098d04b3a57409c947ec1c75 (patch) | |
tree | 152d5b23718ae8d019dd85886429db8c32987245 /core/java/android/widget/AutoCompleteTextView.java | |
parent | 74dc3e4a1e4f9c4eed3a3619ffc8beff30b3ec0f (diff) | |
download | frameworks_base-fef8d3e4d8f6f46c098d04b3a57409c947ec1c75.zip frameworks_base-fef8d3e4d8f6f46c098d04b3a57409c947ec1c75.tar.gz frameworks_base-fef8d3e4d8f6f46c098d04b3a57409c947ec1c75.tar.bz2 |
Make search UI open up quicker to the user.
On invoking the search UI, the drop down list box with past queries and shortcut items
appears after a few hundreds of milliseconds on screen. This was because we were
displaying the drop down within the onFilterCompleted callback after the list box filtered
the items based on the given query text. While that code path is necessary, for the first
invocation of the search dialog with an empty query we can show the list box before the
text stuff happens. This change does that, issuing an async request to show the drop
down after pending events have been processed.
Without this change, on an average it took 350ms for the code to show the drop down.
With this change, on an average it takes 150ms.
Diffstat (limited to 'core/java/android/widget/AutoCompleteTextView.java')
-rw-r--r-- | core/java/android/widget/AutoCompleteTextView.java | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/core/java/android/widget/AutoCompleteTextView.java b/core/java/android/widget/AutoCompleteTextView.java index e84e5b0..bfa0eff 100644 --- a/core/java/android/widget/AutoCompleteTextView.java +++ b/core/java/android/widget/AutoCompleteTextView.java @@ -124,6 +124,7 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe private boolean mBlockCompletion; private AutoCompleteTextView.ListSelectorHider mHideSelector; + private Runnable mShowDropDownRunnable; private AutoCompleteTextView.PassThroughClickListener mPassThroughClickListener; @@ -1080,6 +1081,13 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe } /** + * Issues a runnable to show the dropdown as soon as possible. + */ + public void showDropDownAfterLayout() { + post(mShowDropDownRunnable); + } + + /** * <p>Displays the drop down on screen.</p> */ public void showDropDown() { @@ -1190,6 +1198,22 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe mHideSelector = new ListSelectorHider(); + /** + * This Runnable exists for the sole purpose of checking if the view layout has got + * completed and if so call showDropDown to display the drop down. This is used to show + * the drop down as soon as possible after user opens up the search dialog, without + * waiting for the normal UI pipeline to do it's job which is slower than this method. + */ + mShowDropDownRunnable = new Runnable() { + public void run() { + // View layout should be all done before displaying the drop down. + View view = getDropDownAnchorView(); + if (view != null && view.getWindowToken() != null) { + showDropDown(); + } + } + }; + mDropDownList = new DropDownListView(context); mDropDownList.setSelector(mDropDownListHighlight); mDropDownList.setAdapter(mAdapter); |