use of android.app.SearchManager in project PocketHub by pockethub.
the class IssueSearchActivity method onCreateOptionsMenu.
@Override
public boolean onCreateOptionsMenu(Menu options) {
getMenuInflater().inflate(R.menu.activity_search, options);
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
MenuItem searchItem = options.findItem(R.id.m_search);
searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
Bundle args = new Bundle();
args.putParcelable(EXTRA_REPOSITORY, repository);
searchView.setAppSearchData(args);
return true;
}
use of android.app.SearchManager in project weiciyuan by qii.
the class AtUserFragment method onCreateOptionsMenu.
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.actionbar_menu_atuserfragment, menu);
SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE);
SearchView searchView = (SearchView) menu.findItem(R.id.search).getActionView();
searchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName()));
searchView.setIconifiedByDefault(false);
searchView.setQueryHint(getString(R.string.at_other));
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
if (!TextUtils.isEmpty(newText)) {
if (task != null) {
task.cancel(true);
}
task = new AtUserTask(newText);
task.executeOnExecutor(MyAsyncTask.THREAD_POOL_EXECUTOR);
} else {
if (task != null) {
task.cancel(true);
}
atList.clear();
result.clear();
atList = AtUsersDBTask.get(GlobalContext.getInstance().getCurrentAccountId());
for (AtUserBean b : atList) {
result.add(b.getNickname());
}
adapter.notifyDataSetChanged();
}
return false;
}
});
searchView.requestFocus();
}
use of android.app.SearchManager in project weiciyuan by qii.
the class SearchMainActivity method onCreateOptionsMenu.
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.actionbar_menu_searchmainactivity, menu);
final SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
final SearchView searchView = (SearchView) menu.findItem(R.id.search).getActionView();
searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
searchView.setImeOptions(EditorInfo.IME_ACTION_SEARCH);
searchView.setIconifiedByDefault(false);
searchView.setSubmitButtonEnabled(false);
searchView.requestFocus();
return super.onCreateOptionsMenu(menu);
}
use of android.app.SearchManager in project platform_frameworks_base by android.
the class SearchManagerTest method testSearchManagerInvocations.
/**
* The goal of this test is to confirm that we can start and then
* stop a simple search.
*/
public void testSearchManagerInvocations() throws Exception {
SearchManager searchManager = (SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE);
assertNotNull(searchManager);
// These tests should simply run to completion w/o exceptions
searchManager.startSearch(null, false, SEARCHABLE_ACTIVITY, null, false);
searchManager.stopSearch();
searchManager.startSearch("", false, SEARCHABLE_ACTIVITY, null, false);
searchManager.stopSearch();
searchManager.startSearch("test search string", false, SEARCHABLE_ACTIVITY, null, false);
searchManager.stopSearch();
searchManager.startSearch("test search string", true, SEARCHABLE_ACTIVITY, null, false);
searchManager.stopSearch();
}
use of android.app.SearchManager in project platform_frameworks_base by android.
the class SearchManagerTest method testSearchManagerAvailable.
/**
* The goal of this test is to confirm that we can obtain
* a search manager at any time, and that for any given context,
* it is a singleton.
*/
@LargeTest
public void testSearchManagerAvailable() {
SearchManager searchManager1 = (SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE);
assertNotNull(searchManager1);
SearchManager searchManager2 = (SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE);
assertNotNull(searchManager2);
assertSame(searchManager1, searchManager2);
}
Aggregations