本文整理汇总了Java中android.widget.FilterQueryProvider类的典型用法代码示例。如果您正苦于以下问题:Java FilterQueryProvider类的具体用法?Java FilterQueryProvider怎么用?Java FilterQueryProvider使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FilterQueryProvider类属于android.widget包,在下文中一共展示了FilterQueryProvider类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: SearchSuggestionAdapter
import android.widget.FilterQueryProvider; //导入依赖的package包/类
public SearchSuggestionAdapter(Context context, int layout, Cursor c, String[] from, int[] to, int flags) {
super(context, layout, c, from, to, flags);
setFilterQueryProvider(new FilterQueryProvider() {
public Cursor runQuery(CharSequence constraint) {
MatrixCursor matrixCursor = new MatrixCursor(new String[] { "_id", "item" });
if(constraint == null) return matrixCursor;
String query = constraint.toString();
if(TextUtils.isEmpty(query)) return matrixCursor;
String suggestions[] = Parser.getInstance().getSearchSuggestions(query);
if(suggestions == null) return matrixCursor;
for (int i = 0; i < suggestions.length; i++) {
matrixCursor.addRow(new Object[]{(i + 1), suggestions[i]});
}
return matrixCursor;
}
});
}
示例2: prepareSearch
import android.widget.FilterQueryProvider; //导入依赖的package包/类
public void prepareSearch(CharSequence query) {
if (mRecyclerView == null) return;
Cursor cursor = null;
if (!TextUtils.isEmpty(query)) {
cursor = SearchQueryHelper.getInstance(getContext()).query(query);
} else {
cursor = SearchQueryHelper.getInstance(getContext()).querySuggestWord();
}
mListAdapter = new SearchListAdapter(getContext(), cursor, DictionaryDataProvider.COLUMN_WORD,
mRecyclerView, Constants.SEARCH_LIST_ITEM_LIMIT);
mListAdapter.setFilterQueryProvider(new FilterQueryProvider() {
@Override
public Cursor runQuery(CharSequence constraint) {
return SearchQueryHelper.getInstance(getContext()).query(constraint);
}
});
mListAdapter.setOnItemClickListener(this);
mRecyclerView.setAdapter(mListAdapter);
}
示例3: getAutoCompleteAdapter
import android.widget.FilterQueryProvider; //导入依赖的package包/类
/**
* @param context this
* @param layout support_simple_spinner_dropdown_item
* @return
*/
public ListAdapter getAutoCompleteAdapter(Context context, int layout) {
SimpleCursorAdapter adapter =
new SimpleCursorAdapter(context, layout,
null,
new String[]{FIELD_HWD},
new int[]{android.R.id.text1},
0
);
adapter.setFilterQueryProvider(
new FilterQueryProvider() {
@Override
public Cursor runQuery(CharSequence constraint) {
return getFilterCursor(constraint.toString());
}
}
);
adapter.setCursorToStringConverter(
new SimpleCursorAdapter.CursorToStringConverter() {
@Override
public CharSequence convertToString(Cursor cursor) {
return cursor.getString(1);
}
}
);
return adapter;
}
示例4: getAutoCompleteAdapter
import android.widget.FilterQueryProvider; //导入依赖的package包/类
public ListAdapter getAutoCompleteAdapter(Context context, int layout) {
SimpleCursorAdapter adapter =
new SimpleCursorAdapter(context, layout,
null,
new String[]{"hwd"},
new int[]{android.R.id.text1},
0
);
adapter.setFilterQueryProvider(
new FilterQueryProvider() {
@Override
public Cursor runQuery(CharSequence constraint) {
return getFilterCursor(constraint.toString());
}
}
);
adapter.setCursorToStringConverter(
new SimpleCursorAdapter.CursorToStringConverter() {
@Override
public CharSequence convertToString(Cursor cursor) {
return cursor.getString(1);
}
}
);
return adapter;
}
示例5: getAutoCompleteAdapter
import android.widget.FilterQueryProvider; //导入依赖的package包/类
@Override
public ListAdapter getAutoCompleteAdapter(Context context, int layout) {
SimpleCursorAdapter adapter =
new SimpleCursorAdapter(context, layout, null,
new String[] {CustomDictionaryDbHelper.getHeadwordColumnName()},
new int[] {android.R.id.text1},
0
);
adapter.setFilterQueryProvider(
new FilterQueryProvider() {
@Override
public Cursor runQuery(CharSequence constraint) {
return mDbHelper.getFilterCursor(mDictId, constraint.toString());
}
}
);
adapter.setCursorToStringConverter(
new SimpleCursorAdapter.CursorToStringConverter() {
@Override
public CharSequence convertToString(Cursor cursor) {
return cursor.getString(1);
}
}
);
return adapter;
}
示例6: EditSummaryHandler
import android.widget.FilterQueryProvider; //导入依赖的package包/类
public EditSummaryHandler(final Activity activity, View container,
AutoCompleteTextView summaryEditText, PageTitle title) {
this.activity = activity;
this.container = container;
this.summaryEdit = summaryEditText;
this.container.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
summaryEdit.requestFocus();
}
});
EditSummaryAdapter adapter = new EditSummaryAdapter(activity, null, true);
summaryEdit.setAdapter(adapter);
adapter.setFilterQueryProvider(new FilterQueryProvider() {
@Override
public Cursor runQuery(CharSequence charSequence) {
ContentProviderClient client = activity.getContentResolver()
.acquireContentProviderClient(EditSummary.PERSISTENCE_HELPER
.getBaseContentURI());
try {
return client.query(
EditSummary.PERSISTENCE_HELPER.getBaseContentURI(),
null,
"summary LIKE ?",
new String[] {charSequence + "%"},
"lastUsed DESC");
} catch (RemoteException e) {
// This shouldn't really be happening
throw new RuntimeException(e);
} finally {
client.release();
}
}
});
setConditionalTextDirection(summaryEdit, title.getSite().getLanguageCode());
}
示例7: LyricCursorAdapter
import android.widget.FilterQueryProvider; //导入依赖的package包/类
public LyricCursorAdapter(final Context context, int layout, Cursor c, String[] from, int[] to, int flags) {
super(context, layout, c, from, to, flags);
setFilterQueryProvider(new FilterQueryProvider() {
@Override
public Cursor runQuery(CharSequence constraint) {
LogUtils.d(TAG, "runQuery: " + constraint);
return DbUtils.searchByKeyword(context.getContentResolver(), constraint.toString());
}
});
}
示例8: runQueryOnBackgroundThread
import android.widget.FilterQueryProvider; //导入依赖的package包/类
@Override
public Cursor runQueryOnBackgroundThread(CharSequence constraint) {
FilterQueryProvider filter = getFilterQueryProvider();
if (filter != null) {
return filter.runQuery(constraint);
}
Uri uri = Uri.withAppendedPath(
Contacts.CONTENT_FILTER_URI,
Uri.encode(constraint.toString()));
return mContent.query(uri, CONTACT_PROJECTION, null, null, null);
}
示例9: createSearchFilterQueryProvider
import android.widget.FilterQueryProvider; //导入依赖的package包/类
/**
* Creates a SearchFilterProvider that searches through the columns set in {@link #setSearchColumns(String...)}.
* @param context
* @return
*/
public FilterQueryProvider createSearchFilterQueryProvider( final Context context, final Uri uri ) {
return new FilterQueryProvider() {
public Cursor runQuery(CharSequence constraint) {
setSearchQuery( TextUtils.isEmpty( constraint ) ? null : constraint.toString() );
return query( context, uri );
}
};
}
示例10: onLoadFinished
import android.widget.FilterQueryProvider; //导入依赖的package包/类
@Override
public void onLoadFinished(Loader loader, Cursor cursor) {
Log.v(TAG, "Cursor retrieved");
mCustomCursorAdapter = new CustomCursorAdapter(MainActivity.this, R.layout.story_layout,
cursor, MainDatabase.TableStory.COLUMNS_SHOWN, to, 0, this);
mStoriesGridView.setAdapter(mCustomCursorAdapter);
mCustomCursorAdapter.setFilterQueryProvider(new FilterQueryProvider() {
@Override
public Cursor runQuery(CharSequence constraint) {
return mStoryDataLayer.searchStoryByText(constraint.toString());
}
});
setSupportProgressBarIndeterminateVisibility(false);
}
示例11: onLoadFinished
import android.widget.FilterQueryProvider; //导入依赖的package包/类
@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) {
ListAdapter adapter = getListAdapter();
FragmentActivity activity = getActivity();
if (activity == null) {
return;
}
if (adapter == null || !(adapter instanceof CursorAdapter)) {
BaseAdapter baseAdapter = createAdapter(activity, cursor);
ViewBinder adapterViewBinder = getAdapterViewBinder();
if (adapterViewBinder != null && baseAdapter instanceof ISetViewBinder) {
((ISetViewBinder)baseAdapter).setViewBinder(adapterViewBinder);
}
if (baseAdapter instanceof CursorAdapter) {
((CursorAdapter)baseAdapter).setFilterQueryProvider(new FilterQueryProvider() {
@Override
public Cursor runQuery(CharSequence constraint) {
return runSearchQuery(getActivity(), constraint);
}
});
}
adapter = baseAdapter;
setListAdapter(adapter);
} else {
((CursorAdapter) adapter).swapCursor(cursor);
}
//plugins
List<IFragmentPlugin> listFragmentPlugins = XCoreHelper.get(getActivity()).getListFragmentPlugins();
if (listFragmentPlugins != null) {
for(IFragmentPlugin plugin : listFragmentPlugins) {
plugin.onLoadFinished(this, loader, cursor);
}
}
setLoaderWork(false, LOADER_PRIORITY_HIGH);
checkStatus("onLoadFinished");
}
示例12: getFilterQueryProvider
import android.widget.FilterQueryProvider; //导入依赖的package包/类
public FilterQueryProvider getFilterQueryProvider() {
return this.mFilterQueryProvider;
}
示例13: setFilterQueryProvider
import android.widget.FilterQueryProvider; //导入依赖的package包/类
public void setFilterQueryProvider(FilterQueryProvider filterQueryProvider) {
this.mFilterQueryProvider = filterQueryProvider;
}
示例14: onCreateOptionsMenu
import android.widget.FilterQueryProvider; //导入依赖的package包/类
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater){
inflater.inflate(R.menu.menu_catalog, menu);
MenuItem replyButton = menu.findItem(R.id.action_reply);
MenuItem openExternalButton = menu.findItem(R.id.action_external_browser);
MenuItem menuLayout = menu.findItem(R.id.action_menu_layout);
MenuItem shareButton = menu.findItem(R.id.menu_item_share);
MenuItem sortBy = menu.findItem(R.id.action_sort_by);
replyButton.setVisible(true);
openExternalButton.setVisible(true);
menuLayout.setVisible(true);
sortBy.setVisible(true);
shareButton.setVisible(true);
shareActionProvider = MenuItemCompat.getActionProvider(shareButton);
MenuItem searchButton = menu.findItem(R.id.action_search);
searchButton.setVisible(true);
SearchView searchView = (SearchView) searchButton.getActionView();
searchView.setIconifiedByDefault(false);
searchView.setSubmitButtonEnabled(false);
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
Log.d(LOG_TAG, "query=" + newText);
catalogAdapter.setFilterQueryProvider(new FilterQueryProvider() {
@Override
public Cursor runQuery(CharSequence constraint) {
return infiniteDbHelper.searchCatalogForThread(constraint.toString(), SettingsHelper.getSortByMethod(getContext()));
}
});
catalogAdapter.getFilter().filter(newText);
return true;
}
});
}
示例15: onCreateOptionsMenu
import android.widget.FilterQueryProvider; //导入依赖的package包/类
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
MenuItem goToBottomButton = menu.findItem(R.id.action_scroll_bottom);
MenuItem goToTopButton = menu.findItem(R.id.action_scroll_top);
MenuItem replyButton = menu.findItem(R.id.action_reply);
MenuItem watchlistButton = menu.findItem(R.id.action_add_watchlist);
MenuItem refreshButton = menu.findItem(R.id.action_refresh);
MenuItem galleryButton = menu.findItem(R.id.action_gallery);
MenuItem saveAllImagesButton = menu.findItem(R.id.action_save_all_images);
MenuItem openExternalButton = menu.findItem(R.id.action_external_browser);
MenuItem shareButton = menu.findItem(R.id.menu_item_share);
MenuItem menuLayout = menu.findItem(R.id.action_menu_layout);
MenuItem searchButton = menu.findItem(R.id.action_search);
searchButton.setVisible(true);
final SearchView searchView = (SearchView) searchButton.getActionView();
searchView.setIconifiedByDefault(false);
searchView.setSubmitButtonEnabled(false);
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
threadAdapter.setFilterQueryProvider(new FilterQueryProvider() {
@Override
public Cursor runQuery(CharSequence constraint) {
return infiniteDbHelper.searchThreadForString(constraint.toString(), resto);
}
});
threadAdapter.getFilter().filter(newText);
return true;
}
});
MenuItemCompat.setOnActionExpandListener(searchButton, this);
refreshButton.setVisible(true);
goToBottomButton.setVisible(true);
goToTopButton.setVisible(true);
replyButton.setVisible(true);
galleryButton.setVisible(true);
saveAllImagesButton.setVisible(true);
openExternalButton.setVisible(true);
shareButton.setVisible(true);
watchlistButton.setVisible(true);
menuLayout.setVisible(true);
super.onCreateOptionsMenu(menu, inflater);
}