Search in sources :

Example 61 with SearchView

use of android.support.v7.widget.SearchView in project Android-Password-Store by zeapo.

the class AutofillPreferenceActivity method onCreateOptionsMenu.

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.autofill_preference, menu);
    MenuItem searchItem = menu.findItem(R.id.action_search);
    SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {

        @Override
        public boolean onQueryTextSubmit(String s) {
            return false;
        }

        @Override
        public boolean onQueryTextChange(String s) {
            if (recyclerAdapter != null) {
                recyclerAdapter.filter(s);
            }
            return true;
        }
    });
    return super.onCreateOptionsMenu(menu);
}
Also used : SearchView(android.support.v7.widget.SearchView) MenuItem(android.view.MenuItem)

Example 62 with SearchView

use of android.support.v7.widget.SearchView in project Zom-Android by zom.

the class MainActivity method onCreateOptionsMenu.

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.menu_main, menu);
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    mSearchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.menu_search));
    if (mSearchView != null) {
        mSearchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
        mSearchView.setIconifiedByDefault(false);
        SearchView.OnQueryTextListener queryTextListener = new SearchView.OnQueryTextListener() {

            public boolean onQueryTextChange(String query) {
                if (mTabLayout.getSelectedTabPosition() == 0)
                    mConversationList.doSearch(query);
                else if (mTabLayout.getSelectedTabPosition() == 1)
                    mContactList.doSearch(query);
                return true;
            }

            public boolean onQueryTextSubmit(String query) {
                if (mTabLayout.getSelectedTabPosition() == 0)
                    mConversationList.doSearch(query);
                else if (mTabLayout.getSelectedTabPosition() == 1)
                    mContactList.doSearch(query);
                return true;
            }
        };
        mSearchView.setOnQueryTextListener(queryTextListener);
        mSearchView.setOnCloseListener(new SearchView.OnCloseListener() {

            @Override
            public boolean onClose() {
                mConversationList.doSearch(null);
                return false;
            }
        });
    }
    MenuItem mItem = menu.findItem(R.id.menu_lock_reset);
    SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this);
    if (!settings.contains(ImApp.PREFERENCE_KEY_TEMP_PASS))
        mItem.setVisible(true);
    return true;
}
Also used : SearchView(android.support.v7.widget.SearchView) SearchManager(android.app.SearchManager) SharedPreferences(android.content.SharedPreferences) MenuItem(android.view.MenuItem)

Example 63 with SearchView

use of android.support.v7.widget.SearchView in project Zom-Android by zom.

the class ContactsPickerActivity method onCreateOptionsMenu.

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.contact_list_menu, menu);
    mMenuStartGroupChat = menu.findItem(R.id.action_start_chat);
    updateStartGroupChatMenu();
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    mSearchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.menu_search));
    if (mSearchView != null) {
        mSearchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
        mSearchView.setIconifiedByDefault(false);
        SearchView.OnQueryTextListener queryTextListener = new SearchView.OnQueryTextListener() {

            public boolean onQueryTextChange(String newText) {
                mSearchString = newText;
                doFilterAsync(mSearchString);
                return true;
            }

            public boolean onQueryTextSubmit(String query) {
                mSearchString = query;
                doFilterAsync(mSearchString);
                return true;
            }
        };
        mSearchView.setOnQueryTextListener(queryTextListener);
    }
    return true;
}
Also used : SearchView(android.support.v7.widget.SearchView) MenuInflater(android.view.MenuInflater) SearchManager(android.app.SearchManager)

Example 64 with SearchView

use of android.support.v7.widget.SearchView in project Vivir by yogendra-nitc.

the class RegUserSearch method onCreateOptionsMenu.

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.search_file, menu);
    final MenuItem myActionMenuItem = menu.findItem(R.id.search);
    searchView = (SearchView) myActionMenuItem.getActionView();
    changeSearchViewTextColor(searchView);
    ((EditText) searchView.findViewById(android.support.v7.appcompat.R.id.search_src_text)).setHintTextColor(getResources().getColor(R.color.colorAccent));
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {

        @Override
        public boolean onQueryTextSubmit(String query) {
            if (!searchView.isIconified()) {
                searchView.setIconified(true);
            }
            myActionMenuItem.collapseActionView();
            return false;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            final List<SearchItem> filtermodelist = filter(flatList, newText);
            adapter.setfilter(filtermodelist);
            return true;
        }
    });
    return true;
}
Also used : EditText(android.widget.EditText) SearchView(android.support.v7.widget.SearchView) MenuItem(android.view.MenuItem) ArrayList(java.util.ArrayList) List(java.util.List)

Example 65 with SearchView

use of android.support.v7.widget.SearchView in project Osmand by osmandapp.

the class AvailableGPXFragment method onCreateOptionsMenu.

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    menu.clear();
    MenuItem mi = createMenuItem(menu, SEARCH_ID, R.string.search_poi_filter, R.drawable.ic_action_search_dark, R.drawable.ic_action_search_dark, MenuItemCompat.SHOW_AS_ACTION_ALWAYS | MenuItemCompat.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
    SearchView searchView = new SearchView(getActivity());
    FavoritesActivity.updateSearchView(getActivity(), searchView);
    MenuItemCompat.setActionView(mi, searchView);
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {

        @Override
        public boolean onQueryTextSubmit(String query) {
            allGpxAdapter.getFilter().filter(query);
            return true;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            allGpxAdapter.getFilter().filter(newText);
            return true;
        }
    });
    MenuItemCompat.setOnActionExpandListener(mi, new MenuItemCompat.OnActionExpandListener() {

        @Override
        public boolean onMenuItemActionExpand(MenuItem item) {
            return true;
        }

        @Override
        public boolean onMenuItemActionCollapse(MenuItem item) {
            // Needed to hide intermediate progress bar after closing action mode
            new Handler().postDelayed(new Runnable() {

                public void run() {
                    hideProgressBar();
                }
            }, 100);
            return true;
        }
    });
    if (AndroidUiHelper.isOrientationPortrait(getActivity())) {
        menu = ((FavoritesActivity) getActivity()).getClearToolbar(true).getMenu();
    } else {
        ((FavoritesActivity) getActivity()).getClearToolbar(false);
    }
    ((FavoritesActivity) getActivity()).updateListViewFooter(footerView);
    // TODO Rewrite without ContextMenuAdapter
    optionsMenuAdapter = new ContextMenuAdapter();
    ItemClickListener listener = new ContextMenuAdapter.ItemClickListener() {

        @Override
        public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, final int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
            if (itemId == R.string.local_index_mi_reload) {
                reloadTracks();
            } else if (itemId == R.string.shared_string_show_on_map) {
                openShowOnMapMode();
            } else if (itemId == R.string.shared_string_delete) {
                openSelectionMode(itemId, R.drawable.ic_action_delete_dark, R.drawable.ic_action_delete_dark, new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        doAction(itemId);
                    }
                });
            } else if (itemId == R.string.gpx_add_track) {
                addTrack();
            }
            return true;
        }
    };
    optionsMenuAdapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.gpx_add_track, getActivity()).setIcon(R.drawable.ic_action_plus).setListener(listener).createItem());
    optionsMenuAdapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.shared_string_show_on_map, getActivity()).setIcon(R.drawable.ic_show_on_map).setListener(listener).createItem());
    optionsMenuAdapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.shared_string_delete, getActivity()).setIcon(R.drawable.ic_action_delete_dark).setListener(listener).createItem());
    optionsMenuAdapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.local_index_mi_reload, getActivity()).setIcon(R.drawable.ic_action_refresh_dark).setListener(listener).createItem());
    OsmandPlugin.onOptionsMenuActivity(getActivity(), this, optionsMenuAdapter);
    for (int j = 0; j < optionsMenuAdapter.length(); j++) {
        final MenuItem item;
        ContextMenuItem contextMenuItem = optionsMenuAdapter.getItem(j);
        item = menu.add(0, contextMenuItem.getTitleId(), j + 1, contextMenuItem.getTitle());
        MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
        if (AndroidUiHelper.isOrientationPortrait(getActivity())) {
            item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {

                @Override
                public boolean onMenuItemClick(MenuItem menuItem) {
                    onOptionsItemSelected(item);
                    return true;
                }
            });
        }
        if (contextMenuItem.getIcon() != -1) {
            item.setIcon(contextMenuItem.getIcon());
        }
    }
}
Also used : MenuItemCompat(android.support.v4.view.MenuItemCompat) ItemClickListener(net.osmand.plus.ContextMenuAdapter.ItemClickListener) ContextMenuItem(net.osmand.plus.ContextMenuItem) DialogInterface(android.content.DialogInterface) Handler(android.os.Handler) MenuItem(android.view.MenuItem) ContextMenuItem(net.osmand.plus.ContextMenuItem) ContextMenuAdapter(net.osmand.plus.ContextMenuAdapter) SearchView(android.support.v7.widget.SearchView) ArrayAdapter(android.widget.ArrayAdapter)

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