use of android.support.v7.widget.SearchView in project actor-platform by actorapp.
the class GlobalSearchBaseFragment method onCreateOptionsMenu.
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
inflater.inflate(R.menu.fragment_global_search, menu);
searchMenu = menu.findItem(R.id.search);
if (messenger().getAppState().getIsAppEmpty().get()) {
searchMenu.setVisible(false);
} else {
searchMenu.setVisible(true);
}
searchView = (SearchView) searchMenu.getActionView();
searchView.setIconifiedByDefault(true);
MenuItemCompat.setOnActionExpandListener(searchMenu, new MenuItemCompat.OnActionExpandListener() {
@Override
public boolean onMenuItemActionExpand(MenuItem item) {
showSearch();
return true;
}
@Override
public boolean onMenuItemActionCollapse(MenuItem item) {
hideSearch();
return true;
}
});
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String s) {
return false;
}
@Override
public boolean onQueryTextChange(String s) {
searchQuery = s.trim();
if (isSearchVisible) {
if (s.trim().length() > 0) {
String activeSearchQuery = searchQuery;
searchDisplay.initSearch(s.trim().toLowerCase(), false);
scrolledToEnd = false;
searchAdapter.setQuery(s.trim().toLowerCase());
globalSearchResults.clear();
messenger().findPeers(s).start(new CommandCallback<List<PeerSearchEntity>>() {
@Override
public void onResult(List<PeerSearchEntity> res) {
if (searchQuery.equals(activeSearchQuery)) {
int order = 0;
outer: for (PeerSearchEntity pse : res) {
for (int i = 0; i < searchDisplay.getSize(); i++) {
if (searchDisplay.getItem(i).getPeer().equals(pse.getPeer())) {
continue outer;
}
}
Avatar avatar;
Peer peer = pse.getPeer();
String name;
if (peer.getPeerType() == PeerType.PRIVATE) {
UserVM userVM = users().get(peer.getPeerId());
name = userVM.getName().get();
avatar = userVM.getAvatar().get();
} else if (peer.getPeerType() == PeerType.GROUP) {
GroupVM groupVM = groups().get(peer.getPeerId());
name = groupVM.getName().get();
avatar = groupVM.getAvatar().get();
} else {
continue;
}
String optMatchString = pse.getOptMatchString();
globalSearchResults.add(new SearchEntity(pse.getPeer(), order++, avatar, optMatchString == null ? name : optMatchString));
}
if (globalSearchResults.size() > 0) {
globalSearchResults.add(new SearchEntityHeader(order++));
}
checkGlobalSearch();
onSearchChanged();
}
}
@Override
public void onError(Exception e) {
}
});
} else {
searchDisplay.initEmpty();
}
}
return false;
}
});
}
use of android.support.v7.widget.SearchView in project Signal-Android by WhisperSystems.
the class ConversationListActivity method initializeSearch.
private void initializeSearch(MenuItem searchViewItem) {
SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchViewItem);
searchView.setQueryHint(getString(R.string.ConversationListActivity_search));
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
if (fragment != null) {
fragment.setQueryFilter(query);
return true;
}
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
return onQueryTextSubmit(newText);
}
});
MenuItemCompat.setOnActionExpandListener(searchViewItem, new MenuItemCompat.OnActionExpandListener() {
@Override
public boolean onMenuItemActionExpand(MenuItem menuItem) {
return true;
}
@Override
public boolean onMenuItemActionCollapse(MenuItem menuItem) {
if (fragment != null) {
fragment.resetQueryFilter();
}
return true;
}
});
}
use of android.support.v7.widget.SearchView in project PocketHub by pockethub.
the class IssuesFragment method onCreateOptionsMenu.
@Override
public void onCreateOptionsMenu(Menu optionsMenu, MenuInflater inflater) {
inflater.inflate(R.menu.fragment_issues, optionsMenu);
SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE);
MenuItem searchItem = optionsMenu.findItem(R.id.m_search);
SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
searchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName()));
Bundle args = new Bundle();
args.putParcelable(EXTRA_REPOSITORY, repository);
searchView.setAppSearchData(args);
}
use of android.support.v7.widget.SearchView in project FastAdapter by mikepenz.
the class SimpleItemListActivity method onCreateOptionsMenu.
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu items for use in the action bar
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.search, menu);
//search icon
menu.findItem(R.id.search).setIcon(new IconicsDrawable(this, MaterialDesignIconic.Icon.gmi_search).color(Color.BLACK).actionBar());
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
final SearchView searchView = (SearchView) menu.findItem(R.id.search).getActionView();
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String s) {
touchCallback.setIsDragEnabled(false);
fastItemAdapter.filter(s);
return true;
}
@Override
public boolean onQueryTextChange(String s) {
fastItemAdapter.filter(s);
touchCallback.setIsDragEnabled(TextUtils.isEmpty(s));
return true;
}
});
} else {
menu.findItem(R.id.search).setVisible(false);
}
return super.onCreateOptionsMenu(menu);
}
use of android.support.v7.widget.SearchView in project NewPipe by TeamNewPipe.
the class SearchInfoItemFragment method onCreateOptionsMenu.
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
inflater.inflate(R.menu.search_menu, menu);
MenuItem searchItem = menu.findItem(R.id.action_search);
SearchView searchView = (SearchView) searchItem.getActionView();
setupSearchView(searchView);
}
Aggregations