Search in sources :

Example 1 with SearchView

use of android.support.v7.widget.SearchView in project materialistic by hidroh.

the class FavoriteActivityTest method testSearchView.

@Test
public void testSearchView() {
    SearchView searchView = (SearchView) actionViewResolver.getActionView(mock(MenuItem.class));
    verify(searchView, atLeastOnce()).setOnSearchClickListener(searchViewClickListener.capture());
    verify(searchView, atLeastOnce()).setOnCloseListener(searchViewCloseListener.capture());
    searchViewClickListener.getAllValues().get(searchViewClickListener.getAllValues().size() - 1).onClick(searchView);
    assertFalse(((FavoriteFragment) fragment).startActionMode(null));
    SearchView.OnCloseListener closeListener = searchViewCloseListener.getAllValues().get(searchViewCloseListener.getAllValues().size() - 1);
    closeListener.onClose();
    assertEquals(2, adapter.getItemCount());
    ((FavoriteFragment) fragment).filter("ask");
    verify(favoriteManager, times(2)).attach(any(Context.class), any(LoaderManager.class), observerCaptor.capture(), any());
    when(favoriteManager.getSize()).thenReturn(1);
    when(favoriteManager.getItem(eq(0))).thenReturn(new TestFavorite("2", "http://example.com", "ask HN", System.currentTimeMillis()));
    observerCaptor.getValue().onChanged();
    assertEquals(1, adapter.getItemCount());
    reset(searchView);
    closeListener.onClose();
    verify(searchView).setQuery(eq(FavoriteActivity.EMPTY_QUERY), eq(true));
}
Also used : Context(android.content.Context) LoaderManager(android.support.v4.app.LoaderManager) SearchView(android.support.v7.widget.SearchView) TestFavorite(io.github.hidroh.materialistic.data.TestFavorite) SlowTest(io.github.hidroh.materialistic.test.suite.SlowTest) Test(org.junit.Test)

Example 2 with SearchView

use of android.support.v7.widget.SearchView in project FastAdapter by mikepenz.

the class EndlessScrollListActivity 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 (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 3 with SearchView

use of android.support.v7.widget.SearchView in project FastAdapter by mikepenz.

the class SwipeListActivity 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 (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 4 with SearchView

use of android.support.v7.widget.SearchView in project Android-Iconics by mikepenz.

the class MainActivity 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.menu_main, menu);
    //
    menu.findItem(R.id.search).setIcon(new IconicsDrawable(this, MaterialDesignIconic.Icon.gmi_search).color(Color.WHITE).sizeDp(24).respectFontBounds(true));
    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) {
                search(s);
                return true;
            }

            @Override
            public boolean onQueryTextChange(String s) {
                search(s);
                return true;
            }

            private void search(String s) {
                mCurrentSearch = s;
                if (mDrawer != null) {
                    int count = 0;
                    for (ITypeface font : mFonts) {
                        int foundCount = 0;
                        if (font.getIcons() != null) {
                            for (String icon : font.getIcons()) {
                                if (icon.toLowerCase().contains(s.toLowerCase())) {
                                    foundCount++;
                                }
                            }
                        }
                        mDrawer.updateBadge(count, new StringHolder(foundCount + ""));
                        count++;
                    }
                }
                //filter out the current fragment
                if (mIconsFragment != null)
                    mIconsFragment.onSearch(s);
            }
        });
    } else {
        menu.findItem(R.id.search).setVisible(false);
    }
    MenuItem menuItem = menu.findItem(R.id.action_opensource);
    menuItem.setIcon(new IconicsDrawable(this, FontAwesome.Icon.faw_github).actionBar().color(Color.WHITE));
    return super.onCreateOptionsMenu(menu);
}
Also used : StringHolder(com.mikepenz.materialdrawer.holder.StringHolder) SearchView(android.support.v7.widget.SearchView) MenuInflater(android.view.MenuInflater) ITypeface(com.mikepenz.iconics.typeface.ITypeface) MenuItem(android.view.MenuItem) IconicsDrawable(com.mikepenz.iconics.IconicsDrawable)

Example 5 with SearchView

use of android.support.v7.widget.SearchView in project actor-platform by actorapp.

the class BaseContactFragment method onCreateOptionsMenu.

// Search menu
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    if (userSearch) {
        inflater.inflate(R.menu.compose, menu);
        SearchView searchView = (SearchView) menu.findItem(R.id.search).getActionView();
        searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {

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

            @Override
            public boolean onQueryTextChange(String newText) {
                filter(newText);
                return true;
            }
        });
    }
}
Also used : SearchView(android.support.v7.widget.SearchView)

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