当前位置: 首页>>代码示例>>Java>>正文


Java FilterQueryProvider类代码示例

本文整理汇总了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;
        }
    });
}
 
开发者ID:ov3rk1ll,项目名称:KinoCast,代码行数:22,代码来源:SearchSuggestionAdapter.java

示例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);
}
 
开发者ID:soeminnminn,项目名称:EngMyanDictionary,代码行数:23,代码来源:MainListFragment.java

示例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;
}
 
开发者ID:mmjang,项目名称:quiz_helper,代码行数:33,代码来源:Collins.java

示例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;
}
 
开发者ID:mmjang,项目名称:quiz_helper,代码行数:28,代码来源:WebsterLearners.java

示例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;
}
 
开发者ID:mmjang,项目名称:quiz_helper,代码行数:29,代码来源:CustomDictionary.java

示例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());
}
 
开发者ID:gnosygnu,项目名称:xowa_android,代码行数:40,代码来源:EditSummaryHandler.java

示例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());
        }
    });
}
 
开发者ID:markzhai,项目名称:LyricHere,代码行数:11,代码来源:LyricCursorAdapter.java

示例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);
}
 
开发者ID:luoqii,项目名称:ApkLauncher,代码行数:13,代码来源:AutoComplete4.java

示例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 );
		}
	};
}
 
开发者ID:dklisiaris,项目名称:downtown,代码行数:14,代码来源:QueryBuilder.java

示例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);
}
 
开发者ID:jiahaoliuliu,项目名称:StoryTeller,代码行数:16,代码来源:MainActivity.java

示例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");
}
 
开发者ID:IstiN,项目名称:android_xcore,代码行数:39,代码来源:XListFragment.java

示例12: getFilterQueryProvider

import android.widget.FilterQueryProvider; //导入依赖的package包/类
public FilterQueryProvider getFilterQueryProvider() {
    return this.mFilterQueryProvider;
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:4,代码来源:CursorAdapter.java

示例13: setFilterQueryProvider

import android.widget.FilterQueryProvider; //导入依赖的package包/类
public void setFilterQueryProvider(FilterQueryProvider filterQueryProvider) {
    this.mFilterQueryProvider = filterQueryProvider;
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:4,代码来源:CursorAdapter.java

示例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;
        }
    });
}
 
开发者ID:Luorrak,项目名称:Ouroboros,代码行数:42,代码来源:CatalogFragment.java

示例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);
}
 
开发者ID:Luorrak,项目名称:Ouroboros,代码行数:53,代码来源:ThreadFragment.java


注:本文中的android.widget.FilterQueryProvider类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。