本文整理匯總了Java中android.app.SearchableInfo.getSuggestAuthority方法的典型用法代碼示例。如果您正苦於以下問題:Java SearchableInfo.getSuggestAuthority方法的具體用法?Java SearchableInfo.getSuggestAuthority怎麽用?Java SearchableInfo.getSuggestAuthority使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.app.SearchableInfo
的用法示例。
在下文中一共展示了SearchableInfo.getSuggestAuthority方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getSearchManagerSuggestions
import android.app.SearchableInfo; //導入方法依賴的package包/類
Cursor getSearchManagerSuggestions(SearchableInfo searchable, String query, int limit) {
if (searchable == null) {
return null;
}
String authority = searchable.getSuggestAuthority();
if (authority == null) {
return null;
}
Builder uriBuilder = new Builder().scheme(Utils.RESPONSE_CONTENT).authority(authority).query("").fragment("");
String contentPath = searchable.getSuggestPath();
if (contentPath != null) {
uriBuilder.appendEncodedPath(contentPath);
}
uriBuilder.appendPath("search_suggest_query");
String selection = searchable.getSuggestSelection();
String[] selArgs = null;
if (selection != null) {
selArgs = new String[]{query};
} else {
uriBuilder.appendPath(query);
}
if (limit > 0) {
uriBuilder.appendQueryParameter("limit", String.valueOf(limit));
}
return this.mContext.getContentResolver().query(uriBuilder.build(), null, selection, selArgs, null);
}
示例2: setupSearchView
import android.app.SearchableInfo; //導入方法依賴的package包/類
private void setupSearchView(MenuItem searchItem) {
//searchItem.setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
if (searchManager != null) {
List<SearchableInfo> searchables = searchManager.getSearchablesInGlobalSearch();
SearchableInfo info = searchManager.getSearchableInfo(getComponentName());
for (SearchableInfo inf : searchables) {
if (inf.getSuggestAuthority() != null
&& inf.getSuggestAuthority().startsWith("applications")) {
info = inf;
}
}
mSearchView.setSearchableInfo(info);
}
mSearchView.setOnQueryTextListener(this);
}
示例3: setupSearchView
import android.app.SearchableInfo; //導入方法依賴的package包/類
private void setupSearchView(MenuItem searchItem) {
if (isAlwaysExpanded()) {
mSearchView.setIconifiedByDefault(false);
} else {
searchItem.setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_IF_ROOM
| MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
}
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
if (searchManager != null) {
List<SearchableInfo> searchables = searchManager.getSearchablesInGlobalSearch();
// Try to use the "applications" global search provider
SearchableInfo info = searchManager.getSearchableInfo(getComponentName());
for (SearchableInfo inf : searchables) {
if (inf.getSuggestAuthority() != null
&& inf.getSuggestAuthority().startsWith("applications")) {
info = inf;
}
}
mSearchView.setSearchableInfo(info);
}
mSearchView.setOnQueryTextListener(this);
}
示例4: setupSearchView
import android.app.SearchableInfo; //導入方法依賴的package包/類
private void setupSearchView(MenuItem searchItem) {
mSearchView.setIconifiedByDefault(false);
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
if (searchManager != null) {
List<SearchableInfo> searchables = searchManager.getSearchablesInGlobalSearch();
SearchableInfo info = searchManager.getSearchableInfo(getComponentName());
for (SearchableInfo inf : searchables) {
if (inf.getSuggestAuthority() != null
&& inf.getSuggestAuthority().startsWith("applications")) {
info = inf;
}
}
mSearchView.setSearchableInfo(info);
}
mSearchView.setOnQueryTextListener(this);
mSearchView.setFocusable(false);
mSearchView.setFocusableInTouchMode(false);
}
示例5: onCreateOptionsMenu
import android.app.SearchableInfo; //導入方法依賴的package包/類
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
SearchableInfo searchableInfo = getSearchableArgument();
//Se não foi passado um Searchable nos argumentos, nem coloca a ação de Search na ActionBar.
if (searchableInfo == null) {
return;
}
//Coloca a ação de Search baseado no SearchableInfo
inflater.inflate(R.menu.entity_list_fragment_actions, menu);
MenuItem searchMenuItem = menu.findItem(R.id.action_search);
SearchView searchView = (SearchView) searchMenuItem.getActionView();
searchView.setSearchableInfo(searchableInfo);
//O próprio fragmento controla as ações das pesquisas.
SearchQueryTextListener searchListener = new SearchQueryTextListener(searchMenuItem);
searchView.setOnQueryTextListener(searchListener);
String suggestAuthority = searchableInfo.getSuggestAuthority();
//Se possui provedor de sugestões, adiciona ações para a seleção de sugestões e o cadastramento de termos de sugestões.
if (!TextUtils.isEmpty(suggestAuthority)) {
if (!suggestAuthority.equals(EntitySearchSuggestionsProvider.AUTHORITY)) {
//Por enquanto só suporta o provedor de sugestões padrão pois é necessário salvar os termos das pesquisas bem sucedidas através de uma meneira específica.
throw new UnsupportedOperationException("Only the EntitySearchSuggestionsProvider is supported");
}
searchView.setOnSuggestionListener(new SearchSuggestionListener(searchMenuItem, searchView.getSuggestionsAdapter()));
//Seta a informação necessária para salvar os termoas das pesquisas bem sucedidas.
searchListener.setSearchEntity(searchableInfo.getSuggestSelection());
}
}
示例6: m2692a
import android.app.SearchableInfo; //導入方法依賴的package包/類
Cursor m2692a(SearchableInfo searchableInfo, String str, int i) {
if (searchableInfo == null) {
return null;
}
String suggestAuthority = searchableInfo.getSuggestAuthority();
if (suggestAuthority == null) {
return null;
}
String[] strArr;
Builder fragment = new Builder().scheme("content").authority(suggestAuthority).query("").fragment("");
String suggestPath = searchableInfo.getSuggestPath();
if (suggestPath != null) {
fragment.appendEncodedPath(suggestPath);
}
fragment.appendPath("search_suggest_query");
String suggestSelection = searchableInfo.getSuggestSelection();
if (suggestSelection != null) {
strArr = new String[]{str};
} else {
fragment.appendPath(str);
strArr = null;
}
if (i > 0) {
fragment.appendQueryParameter("limit", String.valueOf(i));
}
return this.d.getContentResolver().query(fragment.build(), null, suggestSelection, strArr, null);
}
示例7: onCreateOptionsMenu
import android.app.SearchableInfo; //導入方法依賴的package包/類
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
//menu.clear();
super.onCreateOptionsMenu(menu,inflater);
inflater.inflate(R.menu.product_fragment_menu, menu);
MenuItem searchItem = menu.findItem(R.id.action_search);
SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE);
if (searchView != null) {
List<SearchableInfo> searchables = searchManager.getSearchablesInGlobalSearch();
SearchableInfo info = searchManager.getSearchableInfo(getActivity().getComponentName());
for (SearchableInfo inf : searchables) {
if (inf.getSuggestAuthority() != null && inf.getSuggestAuthority().startsWith("applications")) {
info = inf;
}
}
searchView.setSearchableInfo(info);
searchView.setOnQueryTextListener(this);
searchView.setQueryHint(getActivity().getString(R.string.product_title_search));
if(mQuery != null && mQuery.length() > 0) {
searchView.setQuery(mQuery, true);
searchView.setIconifiedByDefault(false);
searchView.performClick();
searchView.requestFocus();
} else {
searchView.setIconifiedByDefault(true);
}
}
}
示例8: onCreateOptionsMenu
import android.app.SearchableInfo; //導入方法依賴的package包/類
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
//menu.clear();
super.onCreateOptionsMenu(menu,inflater);
inflater.inflate(R.menu.customer_fragment_menu, menu);
MenuItem searchItem = menu.findItem(R.id.action_search);
SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE);
if (searchView != null) {
List<SearchableInfo> searchables = searchManager.getSearchablesInGlobalSearch();
SearchableInfo info = searchManager.getSearchableInfo(getActivity().getComponentName());
for (SearchableInfo inf : searchables) {
if (inf.getSuggestAuthority() != null && inf.getSuggestAuthority().startsWith("applications")) {
info = inf;
}
}
searchView.setSearchableInfo(info);
searchView.setOnQueryTextListener(this);
searchView.setQueryHint(getActivity().getString(R.string.customer_title_search));
if(mQuery != null && mQuery.length() > 0) {
searchView.setQuery(mQuery, true);
searchView.setIconifiedByDefault(false);
searchView.performClick();
searchView.requestFocus();
} else {
searchView.setIconifiedByDefault(true);
}
}
}
示例9: onCreateOptionsMenu
import android.app.SearchableInfo; //導入方法依賴的package包/類
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
//menu.clear();
super.onCreateOptionsMenu(menu,inflater);
inflater.inflate(R.menu.order_fragment_menu, menu);
MenuItem searchItem = menu.findItem(R.id.action_search);
SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE);
if (searchView != null) {
List<SearchableInfo> searchables = searchManager.getSearchablesInGlobalSearch();
SearchableInfo info = searchManager.getSearchableInfo(getActivity().getComponentName());
for (SearchableInfo inf : searchables) {
if (inf.getSuggestAuthority() != null && inf.getSuggestAuthority().startsWith("applications")) {
info = inf;
}
}
searchView.setSearchableInfo(info);
searchView.setOnQueryTextListener(this);
searchView.setQueryHint(getActivity().getString(R.string.order_title_search));
if(mQuery != null && mQuery.length() > 0) {
searchView.setQuery(mQuery, true);
searchView.setIconifiedByDefault(false);
searchView.performClick();
searchView.requestFocus();
} else {
searchView.setIconifiedByDefault(true);
}
}
}
示例10: getSearchManagerSuggestions
import android.app.SearchableInfo; //導入方法依賴的package包/類
Cursor getSearchManagerSuggestions(SearchableInfo searchableinfo, String s, int i)
{
Object obj;
if (searchableinfo != null)
{
if ((obj = searchableinfo.getSuggestAuthority()) != null)
{
obj = (new android.net.Uri.Builder()).scheme("content").authority(((String) (obj))).query("").fragment("");
String s1 = searchableinfo.getSuggestPath();
if (s1 != null)
{
((android.net.Uri.Builder) (obj)).appendEncodedPath(s1);
}
((android.net.Uri.Builder) (obj)).appendPath("search_suggest_query");
s1 = searchableinfo.getSuggestSelection();
searchableinfo = null;
if (s1 != null)
{
searchableinfo = new String[1];
searchableinfo[0] = s;
} else
{
((android.net.Uri.Builder) (obj)).appendPath(s);
}
if (i > 0)
{
((android.net.Uri.Builder) (obj)).appendQueryParameter("limit", String.valueOf(i));
}
s = ((android.net.Uri.Builder) (obj)).build();
return mContext.getContentResolver().query(s, null, s1, searchableinfo, null);
}
}
return null;
}
示例11: getSearchManagerSuggestions
import android.app.SearchableInfo; //導入方法依賴的package包/類
/**
* Import of hidden method: SearchManager.getSuggestions(SearchableInfo, String, int).
*/
Cursor getSearchManagerSuggestions(SearchableInfo searchable, String query, int limit) {
if (searchable == null) {
return null;
}
String authority = searchable.getSuggestAuthority();
if (authority == null) {
return null;
}
Uri.Builder uriBuilder = new Uri.Builder()
.scheme(ContentResolver.SCHEME_CONTENT)
.authority(authority)
.query("") // TODO: Remove, workaround for a bug in Uri.writeToParcel()
.fragment(""); // TODO: Remove, workaround for a bug in Uri.writeToParcel()
// if content path provided, insert it now
final String contentPath = searchable.getSuggestPath();
if (contentPath != null) {
uriBuilder.appendEncodedPath(contentPath);
}
// append standard suggestion query path
uriBuilder.appendPath(SearchManager.SUGGEST_URI_PATH_QUERY);
// get the query selection, may be null
String selection = searchable.getSuggestSelection();
// inject query, either as selection args or inline
String[] selArgs = null;
if (selection != null) { // use selection if provided
selArgs = new String[] { query };
} else { // no selection, use REST pattern
uriBuilder.appendPath(query);
}
if (limit > 0) {
uriBuilder.appendQueryParameter("limit", String.valueOf(limit));
}
Uri uri = uriBuilder.build();
// finally, make the query
return mContext.getContentResolver().query(uri, null, selection, selArgs, null);
}
示例12: getSuggestions
import android.app.SearchableInfo; //導入方法依賴的package包/類
public Cursor getSuggestions(SearchableInfo searchable, String query, int limit) {
if (searchable == null) {
return null;
}
String authority = searchable.getSuggestAuthority();
if (authority == null) {
return null;
}
Uri.Builder uriBuilder = new Uri.Builder()
.scheme(ContentResolver.SCHEME_CONTENT)
.authority(authority)
.query("")
.fragment("");
// if content path provided, insert it now
final String contentPath = searchable.getSuggestPath();
if (contentPath != null) {
uriBuilder.appendEncodedPath(contentPath);
}
// append standard suggestion query path
uriBuilder.appendPath(SearchManager.SUGGEST_URI_PATH_QUERY);
// get the query selection, may be null
String selection = searchable.getSuggestSelection();
// inject query, either as selection args or inline
String[] selArgs = null;
if (selection != null) { // use selection if provided
selArgs = new String[] { query };
} else { // no selection, use REST pattern
uriBuilder.appendPath(query);
}
if (limit > 0) {
uriBuilder.appendQueryParameter("limit", String.valueOf(limit));
}
Uri uri = uriBuilder.build();
// finally, make the query
return mContext.getContentResolver().query(uri, null, selection, selArgs, null);
}