Search in sources :

Example 21 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 22 with SearchView

use of android.support.v7.widget.SearchView in project plaid by nickbutcher.

the class SearchActivity method setNoResultsVisibility.

void setNoResultsVisibility(int visibility) {
    if (visibility == View.VISIBLE) {
        if (noResults == null) {
            noResults = (TextView) ((ViewStub) findViewById(R.id.stub_no_search_results)).inflate();
            noResults.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    searchView.setQuery("", false);
                    searchView.requestFocus();
                    ImeUtils.showIme(searchView);
                }
            });
        }
        String message = String.format(getString(R.string.no_search_results), searchView.getQuery().toString());
        SpannableStringBuilder ssb = new SpannableStringBuilder(message);
        ssb.setSpan(new StyleSpan(Typeface.ITALIC), message.indexOf('“') + 1, message.length() - 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        noResults.setText(ssb);
    }
    if (noResults != null) {
        noResults.setVisibility(visibility);
    }
}
Also used : ViewStub(android.view.ViewStub) StyleSpan(android.text.style.StyleSpan) BindView(butterknife.BindView) View(android.view.View) SearchView(android.widget.SearchView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) CheckedTextView(android.widget.CheckedTextView) SpannableStringBuilder(android.text.SpannableStringBuilder)

Example 23 with SearchView

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

the class SearchShareesFragment method onStart.

@Override
public void onStart() {
    super.onStart();
    // focus the search view and request the software keyboard be shown
    View searchView = getView().findViewById(R.id.searchView);
    if (searchView.requestFocus()) {
        InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
        if (imm != null) {
            imm.showSoftInput(searchView.findFocus(), InputMethodManager.SHOW_IMPLICIT);
        }
    }
}
Also used : InputMethodManager(android.view.inputmethod.InputMethodManager) SearchView(android.support.v7.widget.SearchView) View(android.view.View) ListView(android.widget.ListView)

Example 24 with SearchView

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

the class SearchShareesFragment method onCreateView.

/**
     * {@inheritDoc}
     */
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View view = inflater.inflate(R.layout.search_users_groups_layout, container, false);
    // Get the SearchView and set the searchable configuration
    SearchView searchView = (SearchView) view.findViewById(R.id.searchView);
    SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE);
    searchView.setSearchableInfo(searchManager.getSearchableInfo(// assumes parent activity is the searchable activity
    getActivity().getComponentName()));
    // do not iconify the widget; expand it by default
    searchView.setIconifiedByDefault(false);
    // avoid fullscreen with softkeyboard
    searchView.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI);
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {

        @Override
        public boolean onQueryTextSubmit(String query) {
            Log_OC.v(TAG, "onQueryTextSubmit intercepted, query: " + query);
            // return true to prevent the query is processed to be queried;
            return true;
        // a user / group will be picked only if selected in the list of suggestions
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            // let it for the parent listener in the hierarchy / default behaviour
            return false;
        }
    });
    return view;
}
Also used : SearchView(android.support.v7.widget.SearchView) SearchManager(android.app.SearchManager) SearchView(android.support.v7.widget.SearchView) View(android.view.View) ListView(android.widget.ListView)

Example 25 with SearchView

use of android.support.v7.widget.SearchView in project Talon-for-Twitter by klinker24.

the class GiphySearch method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    try {
        getWindow().requestFeature(Window.FEATURE_NO_TITLE);
    } catch (Exception e) {
    }
    setContentView(R.layout.giffy_search_activity);
    recycler = (RecyclerView) findViewById(R.id.recycler_view);
    progressSpinner = findViewById(R.id.list_progress);
    backArrow = (ImageView) findViewById(R.id.imageView_arrow_back);
    toolbar = (SearchView) findViewById(R.id.searchView);
    searchText = (EditText) findViewById(R.id.editText_input);
    final ArrowDrawable drawable = new ArrowDrawable(this);
    drawable.animate(ArrowDrawable.STATE_ARROW);
    backArrow.setImageDrawable(drawable);
    toolbar.setOnSearchMenuListener(new SearchView.SearchMenuListener() {

        @Override
        public void onMenuClick() {
            setResult(Activity.RESULT_CANCELED);
            finish();
        }
    });
    toolbar.setOnQueryTextListener(new SearchView.OnQueryTextListener() {

        @Override
        public boolean onQueryTextSubmit(String query) {
            executeQuery(query);
            backArrow.performClick();
            return true;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            return false;
        }
    });
    recycler.setOnScrollListener(new RecyclerView.OnScrollListener() {

        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            super.onScrolled(recyclerView, dx, dy);
            adapter.releaseVideo();
        }
    });
    new Handler().postDelayed(new Runnable() {

        @Override
        public void run() {
            drawable.animate(ArrowDrawable.STATE_ARROW);
            loadTrending();
        }
    }, 750);
}
Also used : ArrowDrawable(com.lapism.arrow.ArrowDrawable) SearchView(com.lapism.searchview.view.SearchView) Handler(android.os.Handler) RecyclerView(android.support.v7.widget.RecyclerView)

Aggregations

SearchView (android.support.v7.widget.SearchView)67 MenuItem (android.view.MenuItem)40 View (android.view.View)19 MenuItemCompat (android.support.v4.view.MenuItemCompat)13 SearchManager (android.app.SearchManager)11 RecyclerView (android.support.v7.widget.RecyclerView)10 MenuInflater (android.view.MenuInflater)10 ImageView (android.widget.ImageView)10 TextView (android.widget.TextView)10 Toolbar (android.support.v7.widget.Toolbar)8 MaterialSearchView (com.miguelcatalan.materialsearchview.MaterialSearchView)7 AdapterView (android.widget.AdapterView)6 ListView (android.widget.ListView)6 SuppressLint (android.annotation.SuppressLint)5 ActionBar (android.support.v7.app.ActionBar)5 Button (android.widget.Button)4 ComponentName (android.content.ComponentName)3 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)3 SpannableString (android.text.SpannableString)3 AutoCompleteTextView (android.widget.AutoCompleteTextView)3