List of usage examples for android.provider SearchRecentSuggestions saveRecentQuery
public void saveRecentQuery(final String queryString, final String line2)
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: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 {/*from ww w . java 2s . c om*/ 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:org.mariotaku.twidere.fragment.SearchFragment.java
@Override public void onActivityCreated(final Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); setHasOptionsMenu(true);/*from w ww . j av a2s . co 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: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 v a 2s . co m }
From source file:com.gm.goldencity.activity.search.SearchActivity.java
@Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); setIntent(intent);//from ww w. ja v a2 s. com 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:de.vanita5.twittnuker.fragment.support.SearchFragment.java
@Override public void onActivityCreated(final Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); setHasOptionsMenu(true);//from ww w . j ava2 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 ww.j av 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:fi.villel.foosquare.SearchActivity.java
@Override public void saveRecentQuery(String query) { SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this, SearchSuggestionProvider.AUTHORITY, SearchSuggestionProvider.MODE); suggestions.saveRecentQuery(query, null); }
From source file:com.dwdesign.tweetings.activity.SearchActivity.java
@Override public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); final Intent intent = getIntent(); mArguments.clear();/*w ww . jav a 2 s . co 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; int search_id = -1; if (mData != null && mData.getQueryParameter(QUERY_PARAM_ID) != null) { search_id = Integer.parseInt(mData.getQueryParameter(QUERY_PARAM_ID)); } 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); mArguments.putInt(INTENT_KEY_ID, search_id); 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.setCustomView(R.layout.base_tabs); mActionBar.setDisplayShowTitleEnabled(false); mActionBar.setDisplayHomeAsUpEnabled(true); mActionBar.setDisplayShowCustomEnabled(true); final View view = mActionBar.getCustomView(); mProgress = (ProgressBar) view.findViewById(android.R.id.progress); mIndicator = (TabPageIndicator) view.findViewById(android.R.id.tabs); mAdapter = new TabsAdapter(this, getSupportFragmentManager(), mIndicator); mAdapter.setDisplayLabel(true); mAdapter.addTab(SearchTweetsFragment.class, mArguments, getString(R.string.search_tweets), R.drawable.ic_tab_twitter, 0); mAdapter.addTab(SearchUsersFragment.class, mArguments, getString(R.string.search_users), R.drawable.ic_tab_person, 1); mViewPager.setAdapter(mAdapter); mViewPager.setOffscreenPageLimit(1); mIndicator.setViewPager(mViewPager); mViewPager.setCurrentItem(is_search_user ? 1 : 0); }
From source file:org.getlantern.firetweet.fragment.support.SearchFragment.java
@Override public void onActivityCreated(final Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); setHasOptionsMenu(true);/*from w w w . j a v a2 s. c om*/ final Bundle args = getArguments(); final FragmentActivity activity = getActivity(); mAdapter = new SupportTabsAdapter(activity, getChildFragmentManager(), null, 1); mAdapter.addTab(StatusesSearchFragment.class, args, getString(R.string.statuses), R.drawable.ic_action_twitter, 0, null); mAdapter.addTab(SearchUsersFragment.class, args, getString(R.string.users), R.drawable.ic_action_user, 1, null); mViewPager.setAdapter(mAdapter); mViewPager.setOffscreenPageLimit(2); mPagerIndicator.setViewPager(mViewPager); mPagerIndicator.setTabDisplayOption(TabPagerIndicator.LABEL); mPagerIndicator.setOnPageChangeListener(this); ThemeUtils.initPagerIndicatorAsActionBarTab(activity, mPagerIndicator); ThemeUtils.setCompatToolbarOverlay(activity, new EmptyDrawable()); 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); final ContentResolver cr = getContentResolver(); final ContentValues values = new ContentValues(); values.put(SearchHistory.QUERY, query); cr.insert(SearchHistory.CONTENT_URI, values); if (activity instanceof LinkHandlerActivity) { final ActionBar ab = activity.getActionBar(); if (ab != null) { ab.setSubtitle(query); } } } updateTabOffset(); }