當前位置: 首頁>>代碼示例>>Java>>正文


Java SearchableInfo.getSuggestAuthority方法代碼示例

本文整理匯總了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);
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:27,代碼來源:SuggestionsAdapter.java

示例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);
    }
 
開發者ID:dannagle,項目名稱:PacketSender-Android,代碼行數:21,代碼來源:MainActivity.java

示例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);
    }
 
開發者ID:luoqii,項目名稱:ApkLauncher,代碼行數:27,代碼來源:SearchViewActionBar.java

示例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);
    }
 
開發者ID:googlesamples,項目名稱:io2015-codelabs,代碼行數:23,代碼來源:SearchActivity.java

示例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());
	}
	
}
 
開發者ID:ZalemSoftware,項目名稱:Ymir,代碼行數:35,代碼來源:EntityListFragment.java

示例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);
}
 
開發者ID:Qwaz,項目名稱:solved-hacking-problem,代碼行數:28,代碼來源:da.java

示例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);
        }
    }

}
 
開發者ID:BennSandoval,項目名稱:Woodmin,代碼行數:34,代碼來源:ProductsFragment.java

示例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);
        }
    }

}
 
開發者ID:BennSandoval,項目名稱:Woodmin,代碼行數:34,代碼來源:CustomersFragment.java

示例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);
        }
    }

}
 
開發者ID:BennSandoval,項目名稱:Woodmin,代碼行數:34,代碼來源:OrdersFragment.java

示例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;
}
 
開發者ID:Hamz-a,項目名稱:MyCTFWriteUps,代碼行數:35,代碼來源:SuggestionsAdapter.java

示例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);
}
 
開發者ID:GigigoGreenLabs,項目名稱:permissionsModule,代碼行數:48,代碼來源:SuggestionsAdapter.java

示例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);
    }
 
開發者ID:dklisiaris,項目名稱:downtown,代碼行數:46,代碼來源:CustomSuggestionsAdapter.java


注:本文中的android.app.SearchableInfo.getSuggestAuthority方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。