Search in sources :

Example 96 with SearchView

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;
        }
    });
}
Also used : MenuItemCompat(android.support.v4.view.MenuItemCompat) GroupVM(im.actor.core.viewmodel.GroupVM) Peer(im.actor.core.entity.Peer) MenuItem(android.view.MenuItem) Avatar(im.actor.core.entity.Avatar) PeerSearchEntity(im.actor.core.entity.PeerSearchEntity) UserVM(im.actor.core.viewmodel.UserVM) SearchView(android.support.v7.widget.SearchView) SearchEntity(im.actor.core.entity.SearchEntity) PeerSearchEntity(im.actor.core.entity.PeerSearchEntity) ArrayList(java.util.ArrayList) BindedDisplayList(im.actor.runtime.generic.mvvm.BindedDisplayList) List(java.util.List) DisplayList(im.actor.runtime.generic.mvvm.DisplayList) CommandCallback(im.actor.core.viewmodel.CommandCallback)

Example 97 with SearchView

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;
        }
    });
}
Also used : MenuItemCompat(android.support.v4.view.MenuItemCompat) SearchView(android.support.v7.widget.SearchView) MenuItem(android.view.MenuItem)

Example 98 with SearchView

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);
}
Also used : SearchView(android.support.v7.widget.SearchView) SearchManager(android.app.SearchManager) Bundle(android.os.Bundle) MenuItem(android.view.MenuItem)

Example 99 with SearchView

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);
}
Also used : SearchView(android.support.v7.widget.SearchView) MenuInflater(android.view.MenuInflater) IconicsDrawable(com.mikepenz.iconics.IconicsDrawable)

Example 100 with SearchView

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);
}
Also used : SearchView(android.support.v7.widget.SearchView) MenuItem(android.view.MenuItem)

Aggregations

SearchView (android.support.v7.widget.SearchView)151 MenuItem (android.view.MenuItem)88 View (android.view.View)56 SearchManager (android.app.SearchManager)37 RecyclerView (android.support.v7.widget.RecyclerView)35 TextView (android.widget.TextView)26 MenuInflater (android.view.MenuInflater)24 ImageView (android.widget.ImageView)20 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)19 MenuItemCompat (android.support.v4.view.MenuItemCompat)18 Toolbar (android.support.v7.widget.Toolbar)16 SearchView (android.widget.SearchView)12 ArrayList (java.util.ArrayList)11 ViewGroup (android.view.ViewGroup)10 MaterialSearchView (com.miguelcatalan.materialsearchview.MaterialSearchView)10 Intent (android.content.Intent)9 ListView (android.widget.ListView)9 BindView (butterknife.BindView)9 AdapterView (android.widget.AdapterView)8 EditText (android.widget.EditText)8