Search in sources :

Example 1 with OnQueryTextListener

use of androidx.appcompat.widget.SearchView.OnQueryTextListener in project MiMangaNu by raulhaag.

the class ServerListFragment method onCreateOptionsMenu.

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.manga_server, menu);
    MenuItem search;
    search = menu.findItem(R.id.action_search);
    SearchView searchView = (SearchView) MenuItemCompat.getActionView(search);
    searchView.setOnQueryTextListener(new OnQueryTextListener() {

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

        @Override
        public boolean onQueryTextChange(String s) {
            if (adapter != null)
                adapter.getFilter().filter(s);
            return false;
        }
    });
}
Also used : OnQueryTextListener(androidx.appcompat.widget.SearchView.OnQueryTextListener) SearchView(androidx.appcompat.widget.SearchView) MenuItem(android.view.MenuItem)

Example 2 with OnQueryTextListener

use of androidx.appcompat.widget.SearchView.OnQueryTextListener in project MiMangaNu by raulhaag.

the class ServerFilteredNavigationFragment method onCreateOptionsMenu.

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.manga_server_visual, menu);
    MenuItem search = menu.findItem(R.id.action_search);
    if (!serverBase.hasList()) {
        MenuItem item = menu.findItem(R.id.ver_como_lista);
        item.setVisible(false);
    }
    if (serverBase.getServerFilters().length == 0) {
        MenuItem item = menu.findItem(R.id.filter);
        item.setVisible(false);
    }
    if (!serverBase.hasSearch()) {
        MenuItem item = menu.findItem(R.id.action_search);
        item.setVisible(false);
    }
    SearchView searchView = (SearchView) MenuItemCompat.getActionView(search);
    searchView.setOnQueryTextListener(new OnQueryTextListener() {

        @Override
        public boolean onQueryTextSubmit(String value) {
            Bundle bundle = new Bundle();
            bundle.putInt(MainFragment.SERVER_ID, serverBase.getServerID());
            bundle.putString(SearchResultsFragment.TERM, value);
            SearchResultsFragment searchResultsFragment = new SearchResultsFragment();
            searchResultsFragment.setArguments(bundle);
            ((MainActivity) getActivity()).replaceFragment(searchResultsFragment, "SearchFragment");
            return true;
        }

        @Override
        public boolean onQueryTextChange(String s) {
            return false;
        }
    });
}
Also used : OnQueryTextListener(androidx.appcompat.widget.SearchView.OnQueryTextListener) SearchView(androidx.appcompat.widget.SearchView) Bundle(android.os.Bundle) MenuItem(android.view.MenuItem)

Aggregations

MenuItem (android.view.MenuItem)2 SearchView (androidx.appcompat.widget.SearchView)2 OnQueryTextListener (androidx.appcompat.widget.SearchView.OnQueryTextListener)2 Bundle (android.os.Bundle)1