Search in sources :

Example 91 with SearchView

use of android.support.v7.widget.SearchView in project UniPool by divya21raj.

the class HomeActivity method onCreateOptionsMenu.

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.options_menu, menu);
    // Associate searchable configuration with the SearchView
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) menu.findItem(R.id.search).getActionView();
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {

        @Override
        public boolean onQueryTextSubmit(String query) {
            recyclerAdapter.filter(query);
            return true;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            recyclerAdapter.filter(newText);
            return true;
        }
    });
    if (searchManager != null) {
        searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    }
    return true;
}
Also used : SearchView(android.support.v7.widget.SearchView) MenuInflater(android.view.MenuInflater) SearchManager(android.app.SearchManager)

Example 92 with SearchView

use of android.support.v7.widget.SearchView in project kickmaterial by byoutline.

the class SearchListFragment method getSearchView.

public static SearchView getSearchView(Context context, Menu menu) {
    MenuItem item = menu.findItem(R.id.action_search);
    SearchView searchView = (SearchView) item.getActionView();
    searchView.setQueryHint(context.getString(R.string.search_hint));
    return searchView;
}
Also used : SearchView(android.support.v7.widget.SearchView)

Example 93 with SearchView

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

the class SearchFileFragment method onCreateOptionsMenu.

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.picker_search, menu);
    MenuItem searchMenuItem = menu.getItem(0);
    searchView = (SearchView) searchMenuItem.getActionView();
    searchView.setIconified(false);
    int searchPlateId = searchView.getContext().getResources().getIdentifier("android:id/search_plate", null, null);
    View searchPlate = searchView.findViewById(searchPlateId);
    if (searchPlate != null) {
        // searchPlate.setBackgroundColor(Color.DKGRAY);
        int searchTextId = searchPlate.getContext().getResources().getIdentifier("android:id/search_src_text", null, null);
        TextView searchText = (TextView) searchPlate.findViewById(searchTextId);
        if (searchText != null) {
            searchText.setTextColor(Color.WHITE);
            searchText.setHintTextColor(Color.WHITE);
        }
    }
    /*
        SearchViewHacker.setCloseIcon(searchView, R.drawable.bar_clear_search);
        SearchViewHacker.setIcon(searchView, R.drawable.picker_bar_search);
        SearchViewHacker.setText(searchView, getResources().getColor(R.color.picker_file_searchbox_focused_color));
        SearchViewHacker.setEditText(searchView, R.drawable.picker_search_text_box);
        SearchViewHacker.setHint(searchView, getString(R.string.picker_file_search_query_text), 0, getResources().getColor(R.color.picker_file_searchbox_hint_color), null);
        SearchViewHacker.disableMagIcon(searchView);
        */
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {

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

        @Override
        public boolean onQueryTextChange(String query) {
            if (query.equals("")) {
                SearchViewHacker.disableCloseButton(searchView);
                return true;
            } else {
                SearchViewHacker.setCloseIcon(searchView, R.drawable.bar_clear_search);
            }
            SearchFileFragment.this.query = query;
            if (searchingTask != null) {
                searchingTask.cancel(true);
                searchingTask = null;
            }
            File rootFile = new File(root);
            if (root == null || root.equals("")) {
                rootFile = null;
            }
            // progress.show();
            searchingTask = new SearchTask(rootFile, query, index) {

                @Override
                public void onSearchEnded(final ArrayList<ExplorerItem> files) {
                    searchingTask = null;
                    // progress.hide();
                    if (files.isEmpty()) {
                        status.setVisibility(View.VISIBLE);
                        status.setText(R.string.picker_empty);
                        items.clear();
                        adapter.notifyDataSetChanged();
                    // listView.setVisibility(View.GONE);
                    } else {
                        showItems(files);
                    /*
                            AnimationSet outAnimation = new AnimationSet(true);
                            outAnimation.addAnimation(new TranslateAnimation(0, 0, 100, 0));
                            outAnimation.addAnimation(new AlphaAnimation(0,1));
                            outAnimation.setDuration(350);
                            outAnimation.setInterpolator(new MaterialInterpolator());
                            outAnimation.setAnimationListener(new Animation.AnimationListener() {
                                @Override
                                public void onAnimationStart(Animation animation) {
                                    animated = true;
                                }

                                @Override
                                public void onAnimationEnd(Animation animation) {
                                    animated = false;
                                }

                                @Override
                                public void onAnimationRepeat(Animation animation) {

                                }
                            });
                            listView.startAnimation(outAnimation);*/
                    }
                }
            };
            if (indexingTask == null || !index.isEmpty()) {
                searchingTask.execute();
            }
            return false;
        }
    });
    searchView.setOnCloseListener(new SearchView.OnCloseListener() {

        @Override
        public boolean onClose() {
            hideKeyBoard();
            getActivity().onBackPressed();
            return false;
        }
    });
    searchView.setOnQueryTextFocusChangeListener(new View.OnFocusChangeListener() {

        @Override
        public void onFocusChange(View view, boolean b) {
            if (searchView.getQuery().length() == 0) {
                searchView.postDelayed(new Runnable() {

                    @Override
                    public void run() {
                        SearchViewHacker.disableCloseButton(searchView);
                    }
                }, 0);
                SearchViewHacker.disableCloseButton(searchView);
            } else
                SearchViewHacker.setCloseIcon(searchView, R.drawable.bar_clear_search);
        }
    });
    searchView.requestFocusFromTouch();
    SearchViewHacker.disableCloseButton(searchView);
    InputMethodManager inputMethodManager = (InputMethodManager) pickerActivity.getSystemService(Context.INPUT_METHOD_SERVICE);
    inputMethodManager.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
    if (query != null) {
        searchView.setQuery(query, false);
    }
}
Also used : ArrayList(java.util.ArrayList) MenuItem(android.view.MenuItem) InputMethodManager(android.view.inputmethod.InputMethodManager) SearchView(android.support.v7.widget.SearchView) View(android.view.View) AbsListView(android.widget.AbsListView) TextView(android.widget.TextView) ListView(android.widget.ListView) SearchView(android.support.v7.widget.SearchView) SearchTask(im.actor.sdk.controllers.pickers.file.search.SearchTask) TextView(android.widget.TextView) File(java.io.File)

Example 94 with SearchView

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

the class SearchFileFragment method hideKeyBoard.

void hideKeyBoard() {
    if (searchView != null)
        searchView.clearFocus();
    pickerActivity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
    View focusedView = pickerActivity.getCurrentFocus();
    if (focusedView != null) {
        InputMethodManager inputMethodManager = (InputMethodManager) pickerActivity.getSystemService(Context.INPUT_METHOD_SERVICE);
        inputMethodManager.hideSoftInputFromWindow(focusedView.getWindowToken(), InputMethodManager.HIDE_IMPLICIT_ONLY);
    }
}
Also used : InputMethodManager(android.view.inputmethod.InputMethodManager) SearchView(android.support.v7.widget.SearchView) View(android.view.View) AbsListView(android.widget.AbsListView) TextView(android.widget.TextView) ListView(android.widget.ListView)

Example 95 with SearchView

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

the class GlobalSearchBaseFragment method onCreateView.

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View res = inflater.inflate(R.layout.fragment_global_search, container, false);
    res.setVisibility(View.GONE);
    searchList = (RecyclerView) res.findViewById(R.id.searchList);
    searchList.setLayoutManager(new ChatLinearLayoutManager(getActivity()));
    searchList.addOnScrollListener(new RecyclerView.OnScrollListener() {

        @Override
        public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
            if (newState == RecyclerView.SCROLL_STATE_DRAGGING && isSearchVisible) {
                if (searchView != null) {
                    searchView.clearFocus();
                }
            }
        }

        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
        }
    });
    searchContainer = res.findViewById(R.id.searchCont);
    searchContainer.setBackgroundColor(ActorSDK.sharedActor().style.getMainBackgroundColor());
    searchEmptyView = (TextView) res.findViewById(R.id.empty);
    searchHintView = (TextView) res.findViewById(R.id.searchHint);
    searchEmptyView.setTextColor(style.getTextSecondaryColor());
    searchHintView.setTextColor(style.getTextSecondaryColor());
    searchHintView.setVisibility(View.GONE);
    searchEmptyView.setVisibility(View.GONE);
    return res;
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) SearchView(android.support.v7.widget.SearchView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) ChatLinearLayoutManager(android.support.v7.widget.ChatLinearLayoutManager) Nullable(android.support.annotation.Nullable)

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