Force services to be launched as soon as possible when chips are instantiated.
This will redue the pause before seeing result from the first query.
Bug:4691146 butter - warm up contacts autocomplete before user types on compose activity
Change-Id: I6f07284f44824dfe6f25fec27cdd300d9adf7da1
diff --git a/src/com/android/ex/chips/RecipientEditTextView.java b/src/com/android/ex/chips/RecipientEditTextView.java
index 6692553..d476dac 100644
--- a/src/com/android/ex/chips/RecipientEditTextView.java
+++ b/src/com/android/ex/chips/RecipientEditTextView.java
@@ -48,6 +48,8 @@
import android.view.ActionMode.Callback;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
+import android.widget.Filter;
+import android.widget.Filterable;
import android.widget.ListAdapter;
import android.widget.ListPopupWindow;
import android.widget.ListView;
@@ -190,6 +192,17 @@
super.handleMessage(msg);
}
};
+
+ // Start the filtering process as soon as possible. This will
+ // cause any needed services to be started and make the first filter
+ // query come back more quickly.
+ mHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ Filter f = (Filter)((Filterable) getAdapter()).getFilter();
+ f.filter(null);
+ }
+ });
}
@Override