Methods Summary |
---|
public java.lang.CharSequence | convertResultToString(java.lang.Object resultValue)Converts a value from the filtered set into a CharSequence. Subclasses
should override this method to convert their results. The default
implementation returns an empty String for null values or the default
String representation of the value.
return resultValue == null ? "" : resultValue.toString();
|
public final void | filter(java.lang.CharSequence constraint)Starts an asynchronous filtering operation. Calling this method
cancels all previous non-executed filtering requests and posts a new
filtering request that will be executed later.
filter(constraint, null);
|
public final void | filter(java.lang.CharSequence constraint, android.widget.Filter$FilterListener listener)Starts an asynchronous filtering operation. Calling this method
cancels all previous non-executed filtering requests and posts a new
filtering request that will be executed later.
Upon completion, the listener is notified.
synchronized (mLock) {
if (mThreadHandler == null) {
HandlerThread thread = new HandlerThread(THREAD_NAME);
thread.start();
mThreadHandler = new RequestHandler(thread.getLooper());
}
Message message = mThreadHandler.obtainMessage(FILTER_TOKEN);
RequestArguments args = new RequestArguments();
// make sure we use an immutable copy of the constraint, so that
// it doesn't change while the filter operation is in progress
args.constraint = constraint != null ? constraint.toString() : null;
args.listener = listener;
message.obj = args;
mThreadHandler.removeMessages(FILTER_TOKEN);
mThreadHandler.removeMessages(FINISH_TOKEN);
mThreadHandler.sendMessage(message);
}
|
protected abstract android.widget.Filter$FilterResults | performFiltering(java.lang.CharSequence constraint)Invoked in a worker thread to filter the data according to the
constraint. Subclasses must implement this method to perform the
filtering operation. Results computed by the filtering operation
must be returned as a {@link android.widget.Filter.FilterResults} that
will then be published in the UI thread through
{@link #publishResults(CharSequence,
android.widget.Filter.FilterResults)}.
Contract: When the constraint is null, the original
data must be restored.
|
protected abstract void | publishResults(java.lang.CharSequence constraint, android.widget.Filter$FilterResults results)Invoked in the UI thread to publish the filtering results in the
user interface. Subclasses must implement this method to display the
results computed in {@link #performFiltering}.
|