Search in sources :

Example 51 with SearchView

use of android.support.v7.widget.SearchView in project AnExplorer by 1hakr.

the class DocumentsActivity method onCreateOptionsMenu.

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    getMenuInflater().inflate(R.menu.activity, menu);
    final MenuItem searchMenu = menu.findItem(R.id.menu_search);
    mSearchView = (SearchView) MenuItemCompat.getActionView(searchMenu);
    mSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {

        @Override
        public boolean onQueryTextSubmit(String query) {
            mSearchExpanded = mSearchResultShown = true;
            mState.currentSearch = query;
            mSearchView.clearFocus();
            onCurrentDirectoryChanged(ANIM_NONE);
            Bundle params = new Bundle();
            params.putString("query", query);
            AnalyticsManager.logEvent("search", getCurrentRoot(), params);
            return true;
        }

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

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

        @Override
        public boolean onMenuItemActionCollapse(MenuItem item) {
            mSearchExpanded = mSearchResultShown = false;
            if (mIgnoreNextCollapse) {
                mIgnoreNextCollapse = false;
                updateActionBar();
                return true;
            }
            mState.currentSearch = null;
            onCurrentDirectoryChanged(ANIM_NONE);
            return true;
        }
    });
    mSearchView.setOnCloseListener(new SearchView.OnCloseListener() {

        @Override
        public boolean onClose() {
            mSearchExpanded = mSearchResultShown = false;
            if (mIgnoreNextClose) {
                mIgnoreNextClose = false;
                updateActionBar();
                return false;
            }
            mState.currentSearch = null;
            onCurrentDirectoryChanged(ANIM_NONE);
            return false;
        }
    });
    return true;
}
Also used : MenuItemCompat(android.support.v4.view.MenuItemCompat) SearchView(android.support.v7.widget.SearchView) Bundle(android.os.Bundle) MenuItem(android.view.MenuItem)

Example 52 with SearchView

use of android.support.v7.widget.SearchView in project NetGuard by M66B.

the class ActivityMain method updateSearch.

private void updateSearch(String search) {
    if (menuSearch != null) {
        SearchView searchView = (SearchView) menuSearch.getActionView();
        if (search == null) {
            if (menuSearch.isActionViewExpanded())
                adapter.getFilter().filter(searchView.getQuery().toString());
        } else {
            menuSearch.expandActionView();
            searchView.setQuery(search, true);
        }
    }
}
Also used : SearchView(android.support.v7.widget.SearchView)

Example 53 with SearchView

use of android.support.v7.widget.SearchView in project NetGuard by M66B.

the class ActivityMain method onCreateOptionsMenu.

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    if (Build.VERSION.SDK_INT < MIN_SDK)
        return false;
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.main, menu);
    // Search
    menuSearch = menu.findItem(R.id.menu_search);
    menuSearch.setOnActionExpandListener(new MenuItem.OnActionExpandListener() {

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

        @Override
        public boolean onMenuItemActionCollapse(MenuItem item) {
            if (getIntent().hasExtra(EXTRA_SEARCH) && !getIntent().getBooleanExtra(EXTRA_RELATED, false))
                finish();
            return true;
        }
    });
    final SearchView searchView = (SearchView) menuSearch.getActionView();
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {

        @Override
        public boolean onQueryTextSubmit(String query) {
            if (adapter != null)
                adapter.getFilter().filter(query);
            searchView.clearFocus();
            return true;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            if (adapter != null)
                adapter.getFilter().filter(newText);
            return true;
        }
    });
    searchView.setOnCloseListener(new SearchView.OnCloseListener() {

        @Override
        public boolean onClose() {
            Intent intent = getIntent();
            intent.removeExtra(EXTRA_SEARCH);
            if (adapter != null)
                adapter.getFilter().filter(null);
            return true;
        }
    });
    String search = getIntent().getStringExtra(EXTRA_SEARCH);
    if (search != null) {
        menuSearch.expandActionView();
        searchView.setQuery(search, true);
    }
    markPro(menu.findItem(R.id.menu_log), ActivityPro.SKU_LOG);
    if (!IAB.isPurchasedAny(this))
        markPro(menu.findItem(R.id.menu_pro), null);
    if (!Util.hasValidFingerprint(this) || getIntentInvite(this).resolveActivity(getPackageManager()) == null)
        menu.removeItem(R.id.menu_invite);
    if (getIntentSupport().resolveActivity(getPackageManager()) == null)
        menu.removeItem(R.id.menu_support);
    return true;
}
Also used : SearchView(android.support.v7.widget.SearchView) MenuInflater(android.view.MenuInflater) MenuItem(android.view.MenuItem) Intent(android.content.Intent) SpannableString(android.text.SpannableString)

Example 54 with SearchView

use of android.support.v7.widget.SearchView in project malp by gateship-one.

the class FilesFragment method onCreateOptionsMenu.

/**
 * Initialize the options menu.
 * Be sure to call {@link #setHasOptionsMenu} before.
 *
 * @param menu         The container for the custom options menu.
 * @param menuInflater The inflater to instantiate the layout.
 */
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater menuInflater) {
    // Inflate the menu; this adds items to the action bar if it is present.
    menuInflater.inflate(R.menu.fragment_menu_files, menu);
    // get tint color
    int tintColor = ThemeUtils.getThemeColor(getContext(), R.attr.malp_color_text_accent);
    Drawable drawable = menu.findItem(R.id.action_add_directory).getIcon();
    drawable = DrawableCompat.wrap(drawable);
    DrawableCompat.setTint(drawable, tintColor);
    menu.findItem(R.id.action_add_directory).setIcon(drawable);
    drawable = menu.findItem(R.id.action_search).getIcon();
    drawable = DrawableCompat.wrap(drawable);
    DrawableCompat.setTint(drawable, tintColor);
    menu.findItem(R.id.action_search).setIcon(drawable);
    MPDCapabilities serverCaps = MPDInterface.mInstance.getServerCapabilities();
    if (null != serverCaps) {
        if (serverCaps.hasListFiltering()) {
            menu.findItem(R.id.action_show_albums_from_here).setVisible(true);
        }
    }
    SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();
    // Check if a search string is saved from before
    if (mSearchString != null) {
        // Expand the view
        searchView.setIconified(false);
        menu.findItem(R.id.action_search).expandActionView();
        // Set the query string
        searchView.setQuery(mSearchString, false);
        // Notify the adapter
        applyFilter(mSearchString);
    }
    searchView.setOnQueryTextListener(new SearchTextObserver());
    super.onCreateOptionsMenu(menu, menuInflater);
}
Also used : SearchView(android.support.v7.widget.SearchView) Drawable(android.graphics.drawable.Drawable) MPDCapabilities(org.gateshipone.malp.mpdservice.mpdprotocol.MPDCapabilities)

Example 55 with SearchView

use of android.support.v7.widget.SearchView in project MaterialFBook by ZeeRooo.

the class MainActivity method searchToolbar.

// Thanks to Jaison Fernando for the great tutorial.
// http://droidmentor.com/searchview-animation-like-whatsapp/
private void searchToolbar() {
    searchToolbar = findViewById(R.id.searchtoolbar);
    searchToolbar.inflateMenu(R.menu.menu_search);
    Menu search_menu = searchToolbar.getMenu();
    searchItem = search_menu.findItem(R.id.action_filter_search);
    searchView = (SearchView) search_menu.findItem(R.id.action_filter_search).getActionView();
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {

        @Override
        public boolean onQueryTextSubmit(String query) {
            searchView.clearFocus();
            mWebView.loadUrl(baseURL + "search/top/?q=" + query);
            searchItem.collapseActionView();
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
                circleReveal(R.id.searchtoolbar, false);
            else
                searchToolbar.setVisibility(View.INVISIBLE);
            return false;
        }

        @Override
        public boolean onQueryTextChange(final String newText) {
            return false;
        }
    });
    searchItem.setOnActionExpandListener(new MenuItem.OnActionExpandListener() {

        @Override
        public boolean onMenuItemActionCollapse(MenuItem item) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                circleReveal(R.id.searchtoolbar, false);
            } else
                searchToolbar.setVisibility(View.INVISIBLE);
            return true;
        }

        @Override
        public boolean onMenuItemActionExpand(MenuItem item) {
            return true;
        }
    });
}
Also used : SearchView(android.support.v7.widget.SearchView) MenuItem(android.view.MenuItem) FloatingActionMenu(com.github.clans.fab.FloatingActionMenu) Menu(android.view.Menu)

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