Example usage for android.provider SearchRecentSuggestions SearchRecentSuggestions

List of usage examples for android.provider SearchRecentSuggestions SearchRecentSuggestions

Introduction

In this page you can find the example usage for android.provider SearchRecentSuggestions SearchRecentSuggestions.

Prototype

public SearchRecentSuggestions(Context context, String authority, int mode) 

Source Link

Document

Although provider utility classes are typically static, this one must be constructed because it needs to be initialized using the same values that you provided in your android.content.SearchRecentSuggestionsProvider .

Usage

From source file:org.klnusbaum.udj.RegularSearchFragment.java

public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    String query = getActivity().getIntent().getStringExtra(SearchManager.QUERY);
    SearchRecentSuggestions suggestions = new SearchRecentSuggestions(getActivity(),
            MusicSearchSuggestionProvider.AUTHORITY, MusicSearchSuggestionProvider.MODE);
    suggestions.saveRecentQuery(query, null);

}

From source file:io.github.hidroh.materialistic.SearchActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    if (getIntent().hasExtra(SearchManager.QUERY)) {
        mQuery = getIntent().getStringExtra(SearchManager.QUERY);
    }/*  ww  w .  j  a v  a 2 s .  c  o m*/
    super.onCreate(savedInstanceState);
    if (!TextUtils.isEmpty(mQuery)) {
        getSupportActionBar().setSubtitle(mQuery);
        SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this,
                SearchRecentSuggestionsProvider.PROVIDER_AUTHORITY, SearchRecentSuggestionsProvider.MODE) {
            @Override
            public void saveRecentQuery(String queryString, String line2) {
                truncateHistory(getContentResolver(), MAX_RECENT_SUGGESTIONS - 1);
                super.saveRecentQuery(queryString, line2);
            }
        };
        suggestions.saveRecentQuery(mQuery, null);
    }
}

From source file:org.mariotaku.twidere.fragment.SearchFragment.java

@Override
public void onActivityCreated(final Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    setHasOptionsMenu(true);/*from   w  w w .ja  v a2 s . c  o  m*/

    final String query = getQuery();
    if (savedInstanceState == null && !TextUtils.isEmpty(query)) {
        final SearchRecentSuggestions suggestions = new SearchRecentSuggestions(getActivity(),
                RecentSearchProvider.AUTHORITY, RecentSearchProvider.MODE);
        suggestions.saveRecentQuery(query, null);
        final ContentResolver cr = getContentResolver();
        final ContentValues values = new ContentValues();
        values.put(SearchHistory.QUERY, query);
        cr.insert(SearchHistory.CONTENT_URI, values);
    }
}

From source file:com.gm.goldencity.activity.search.SearchActivity.java

@Override
protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);
    setIntent(intent);/*w  w  w .j  av a 2  s  .  co  m*/

    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        if (intent.hasExtra(SearchManager.QUERY)) {
            String query = intent.getStringExtra(SearchManager.QUERY);
            SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this,
                    SuggestionProvider.AUTHORITY, SuggestionProvider.MODE);
            suggestions.saveRecentQuery(query, null);
            if (!TextUtils.isEmpty(query)) {
                searchview.setQuery(query, false);
            }
        }
    }

    initSearchFragment();
}

From source file:ch.ethz.twimight.activities.SearchableActivity.java

private void processIntent(Intent intent) {
    if (intent.hasExtra(SearchManager.QUERY)) {
        //if (!intent.getStringExtra(SearchManager.QUERY).equals(query))
        query = intent.getStringExtra(SearchManager.QUERY);
        setTitle(getString(R.string.results_for) + query);

        SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this,
                TwimightSuggestionProvider.AUTHORITY, TwimightSuggestionProvider.MODE);
        suggestions.saveRecentQuery(query, null);

    }//from   w w w . j  a  va2  s. c  o  m
}

From source file:net.zionsoft.obadiah.ui.activities.SearchActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    App.get(this).getInjectionComponent().inject(this);

    recentSearches = new SearchRecentSuggestions(this, RecentSearchProvider.AUTHORITY,
            RecentSearchProvider.MODE);//from  ww  w . j a v  a 2 s.  c  o  m

    initializeUi();

    nonConfigurationData = (NonConfigurationData) getLastCustomNonConfigurationInstance();
    if (nonConfigurationData == null) {
        nonConfigurationData = new NonConfigurationData();
    } else {
        searchResultListAdapter.setVerses(nonConfigurationData.verses);
    }

    handleStartIntent(getIntent());
}

From source file:de.vanita5.twittnuker.fragment.support.SearchFragment.java

@Override
public void onActivityCreated(final Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    setHasOptionsMenu(true);//from   w ww  . j a va  2  s .  c  o m
    final Bundle args = getArguments();
    final FragmentActivity activity = getActivity();
    mAdapter = new SupportTabsAdapter(activity, getChildFragmentManager(), null, 1);
    mAdapter.addTab(SearchStatusesFragment.class, args, getString(R.string.statuses),
            R.drawable.ic_iconic_action_twitter, 0);
    mAdapter.addTab(SearchUsersFragment.class, args, getString(R.string.users),
            R.drawable.ic_iconic_action_user, 1);
    mViewPager.setAdapter(mAdapter);
    mViewPager.setOnPageChangeListener(this);
    mViewPager.setOffscreenPageLimit(2);
    mPagerIndicator.setSelectedColor(ThemeUtils.getThemeColor(activity));
    mPagerIndicator.setViewPager(mViewPager);
    if (savedInstanceState == null && args != null && args.containsKey(EXTRA_QUERY)) {
        final String query = args.getString(EXTRA_QUERY);
        final SearchRecentSuggestions suggestions = new SearchRecentSuggestions(getActivity(),
                RecentSearchProvider.AUTHORITY, RecentSearchProvider.MODE);
        suggestions.saveRecentQuery(query, null);
        if (activity instanceof LinkHandlerActivity) {
            final ActionBar ab = activity.getActionBar();
            if (ab != null) {
                ab.setSubtitle(query);
            }
        }
    }
}

From source file:org.mariotaku.twidere.activity.SearchActivity.java

@Override
public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setTitle(android.R.string.search_go);
    final Intent intent = getIntent();
    mArguments.clear();/* w  w w.j  a v a2 s .  c  o m*/
    mData = intent.getData();
    final boolean is_search_user = mData != null
            ? QUERY_PARAM_VALUE_USERS.equals(mData.getQueryParameter(QUERY_PARAM_TYPE))
            : false;
    final String query = Intent.ACTION_SEARCH.equals(intent.getAction())
            ? intent.getStringExtra(SearchManager.QUERY)
            : mData != null ? mData.getQueryParameter(QUERY_PARAM_QUERY) : null;
    if (query == null) {
        finish();
        return;
    }
    if (savedInstanceState == null) {
        final SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this,
                RecentSearchProvider.AUTHORITY, RecentSearchProvider.MODE);
        suggestions.saveRecentQuery(query, null);
    }
    mArguments.putString(INTENT_KEY_QUERY, query);
    final String param_account_id = mData != null ? mData.getQueryParameter(QUERY_PARAM_ACCOUNT_ID) : null;
    if (param_account_id != null) {
        mArguments.putLong(INTENT_KEY_ACCOUNT_ID, parseLong(param_account_id));
    } else {
        final String param_account_name = mData != null ? mData.getQueryParameter(QUERY_PARAM_ACCOUNT_NAME)
                : null;
        if (param_account_name != null) {
            mArguments.putLong(INTENT_KEY_ACCOUNT_ID, getAccountId(this, param_account_name));
        } else {
            final long account_id = getDefaultAccountId(this);
            if (isMyAccount(this, account_id)) {
                mArguments.putLong(INTENT_KEY_ACCOUNT_ID, account_id);
            } else {
                finish();
                return;
            }
        }
    }
    mActionBar = getSupportActionBar();
    mActionBar.setDisplayHomeAsUpEnabled(true);
    mAdapter = new TabsAdapter(this, getSupportFragmentManager(), null);
    mAdapter.addTab(SearchTweetsFragment.class, mArguments, getString(R.string.tweets),
            R.drawable.ic_tab_twitter, 0);
    mAdapter.addTab(SearchUsersFragment.class, mArguments, getString(R.string.users), R.drawable.ic_tab_person,
            1);
    mViewPager.setAdapter(mAdapter);
    mViewPager.setCurrentItem(is_search_user ? 1 : 0);
    mPagerTab.setTabIndicatorColorResource(R.color.holo_blue_light);
}

From source file:com.fastbootmobile.encore.app.SearchActivity.java

private void handleIntent(final Intent intent) {
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        if (!intent.hasExtra(SearchManager.QUERY)) {
            Toast.makeText(this, "Invalid search query: missing query", Toast.LENGTH_SHORT).show();
        } else {// w ww.  j  ava 2s  . co m
            final String query = intent.getStringExtra(SearchManager.QUERY).trim();
            mHandler.postDelayed(new Runnable() {
                @Override
                public void run() {
                    mActiveFragment.resetResults();
                    mActiveFragment.setArguments(query);
                    ProviderAggregator.getDefault().startSearch(query);
                }
            }, 200);

            SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this,
                    SearchSuggestionProvider.AUTHORITY, SearchSuggestionProvider.MODE);
            suggestions.saveRecentQuery(query, null);
        }
    }
}

From source file:dev.drsoran.moloko.activities.TaskSearchResultActivity.java

private SearchRecentSuggestions getRecentSuggestions() {
    return new SearchRecentSuggestions(this, TasksSearchRecentSuggestionsProvider.AUTHORITY,
            TasksSearchRecentSuggestionsProvider.MODE);
}