Search in sources :

Example 31 with SearchView

use of android.support.v7.widget.SearchView in project AntennaPod by AntennaPod.

the class ItunesSearchFragment method onCreateOptionsMenu.

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    inflater.inflate(R.menu.itunes_search, menu);
    MenuItem searchItem = menu.findItem(R.id.action_search);
    final SearchView sv = (SearchView) MenuItemCompat.getActionView(searchItem);
    MenuItemUtils.adjustTextColor(getActivity(), sv);
    sv.setQueryHint(getString(R.string.search_itunes_label));
    sv.setOnQueryTextListener(new android.support.v7.widget.SearchView.OnQueryTextListener() {

        @Override
        public boolean onQueryTextSubmit(String s) {
            sv.clearFocus();
            search(s);
            return true;
        }

        @Override
        public boolean onQueryTextChange(String s) {
            return false;
        }
    });
    MenuItemCompat.setOnActionExpandListener(searchItem, new MenuItemCompat.OnActionExpandListener() {

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

        @Override
        public boolean onMenuItemActionCollapse(MenuItem item) {
            if (searchResults != null) {
                searchResults = null;
                updateData(topList);
            }
            return true;
        }
    });
}
Also used : MenuItemCompat(android.support.v4.view.MenuItemCompat) SearchView(android.support.v7.widget.SearchView) MenuItem(android.view.MenuItem)

Example 32 with SearchView

use of android.support.v7.widget.SearchView in project AntennaPod by AntennaPod.

the class FyydSearchFragment method onCreateOptionsMenu.

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    inflater.inflate(R.menu.itunes_search, menu);
    MenuItem searchItem = menu.findItem(R.id.action_search);
    final SearchView sv = (SearchView) MenuItemCompat.getActionView(searchItem);
    MenuItemUtils.adjustTextColor(getActivity(), sv);
    sv.setQueryHint(getString(R.string.search_fyyd_label));
    sv.setOnQueryTextListener(new SearchView.OnQueryTextListener() {

        @Override
        public boolean onQueryTextSubmit(String s) {
            sv.clearFocus();
            search(s);
            return true;
        }

        @Override
        public boolean onQueryTextChange(String s) {
            return false;
        }
    });
    MenuItemCompat.setOnActionExpandListener(searchItem, new MenuItemCompat.OnActionExpandListener() {

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

        @Override
        public boolean onMenuItemActionCollapse(MenuItem item) {
            getActivity().getSupportFragmentManager().popBackStack();
            return true;
        }
    });
    MenuItemCompat.expandActionView(searchItem);
}
Also used : MenuItemCompat(android.support.v4.view.MenuItemCompat) SearchView(android.support.v7.widget.SearchView) MenuItem(android.view.MenuItem)

Example 33 with SearchView

use of android.support.v7.widget.SearchView in project AntennaPod by AntennaPod.

the class AllEpisodesFragment method onCreateOptionsMenu.

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    if (!isAdded()) {
        return;
    }
    super.onCreateOptionsMenu(menu, inflater);
    if (itemsLoaded) {
        inflater.inflate(R.menu.episodes, menu);
        MenuItem searchItem = menu.findItem(R.id.action_search);
        final SearchView sv = (SearchView) MenuItemCompat.getActionView(searchItem);
        MenuItemUtils.adjustTextColor(getActivity(), sv);
        sv.setQueryHint(getString(R.string.search_hint));
        sv.setOnQueryTextListener(new SearchView.OnQueryTextListener() {

            @Override
            public boolean onQueryTextSubmit(String s) {
                sv.clearFocus();
                ((MainActivity) getActivity()).loadChildFragment(SearchFragment.newInstance(s));
                return true;
            }

            @Override
            public boolean onQueryTextChange(String s) {
                return false;
            }
        });
        isUpdatingFeeds = MenuItemUtils.updateRefreshMenuItem(menu, R.id.refresh_item, updateRefreshMenuItemChecker);
    }
}
Also used : SearchView(android.support.v7.widget.SearchView) MenuItem(android.view.MenuItem)

Example 34 with SearchView

use of android.support.v7.widget.SearchView in project AntennaPod by AntennaPod.

the class TagListFragment method onCreateOptionsMenu.

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    inflater.inflate(R.menu.gpodder_podcasts, menu);
    MenuItem searchItem = menu.findItem(R.id.action_search);
    final SearchView sv = (SearchView) MenuItemCompat.getActionView(searchItem);
    MenuItemUtils.adjustTextColor(getActivity(), sv);
    sv.setQueryHint(getString(R.string.gpodnet_search_hint));
    sv.setOnQueryTextListener(new SearchView.OnQueryTextListener() {

        @Override
        public boolean onQueryTextSubmit(String s) {
            Activity activity = getActivity();
            if (activity != null) {
                sv.clearFocus();
                ((MainActivity) activity).loadChildFragment(SearchListFragment.newInstance(s));
            }
            return true;
        }

        @Override
        public boolean onQueryTextChange(String s) {
            return false;
        }
    });
}
Also used : SearchView(android.support.v7.widget.SearchView) MainActivity(de.danoeh.antennapod.activity.MainActivity) Activity(android.app.Activity) MenuItem(android.view.MenuItem)

Example 35 with SearchView

use of android.support.v7.widget.SearchView in project AntennaPod by AntennaPod.

the class SearchFragment method onCreateOptionsMenu.

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    if (itemsLoaded) {
        MenuItem item = menu.add(Menu.NONE, R.id.search_item, Menu.NONE, R.string.search_label);
        MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
        final SearchView sv = new SearchView(getActivity());
        sv.setQueryHint(getString(R.string.search_hint));
        sv.setQuery(getArguments().getString(ARG_QUERY), false);
        sv.setOnQueryTextListener(new SearchView.OnQueryTextListener() {

            @Override
            public boolean onQueryTextSubmit(String s) {
                getArguments().putString(ARG_QUERY, s);
                itemsLoaded = false;
                search();
                return true;
            }

            @Override
            public boolean onQueryTextChange(String s) {
                return false;
            }
        });
        MenuItemCompat.setActionView(item, sv);
    }
}
Also used : SearchView(android.support.v7.widget.SearchView) MenuItem(android.view.MenuItem)

Aggregations

SearchView (android.support.v7.widget.SearchView)74 MenuItem (android.view.MenuItem)47 View (android.view.View)24 SearchManager (android.app.SearchManager)13 MenuItemCompat (android.support.v4.view.MenuItemCompat)13 TextView (android.widget.TextView)13 RecyclerView (android.support.v7.widget.RecyclerView)12 MenuInflater (android.view.MenuInflater)11 ImageView (android.widget.ImageView)11 Toolbar (android.support.v7.widget.Toolbar)9 ListView (android.widget.ListView)8 AdapterView (android.widget.AdapterView)7 MaterialSearchView (com.miguelcatalan.materialsearchview.MaterialSearchView)7 Nullable (android.support.annotation.Nullable)6 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)6 SuppressLint (android.annotation.SuppressLint)5 ActionBar (android.support.v7.app.ActionBar)5 ArrayList (java.util.ArrayList)5 Button (android.widget.Button)4 List (java.util.List)4