Search in sources :

Example 86 with SearchView

use of android.support.v7.widget.SearchView in project wh-app-android by WhiteHouse.

the class MainActivity method configureSearchView.

private void configureSearchView() {
    SearchView searchView = (SearchView) MenuItemCompat.getActionView(mSearchItem);
    searchView.setQueryHint(getString(R.string.search_hint));
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {

        @Override
        public boolean onQueryTextSubmit(String s) {
            mSearchFragment.submitQuery(s);
            mSubmittedSearch = true;
            return false;
        }

        @Override
        public boolean onQueryTextChange(String s) {
            mSearchQuery = s;
            mSubmittedSearch = false;
            return false;
        }
    });
    MenuItemCompat.setOnActionExpandListener(mSearchItem, new MenuItemCompat.OnActionExpandListener() {

        @Override
        public boolean onMenuItemActionExpand(MenuItem item) {
            if (!mSearchVisible) {
                toggleSearch();
            }
            if (mSearchQuery != null) {
                searchView.setQuery(mSearchQuery, false);
            }
            return mSearchVisible;
        }

        @Override
        public boolean onMenuItemActionCollapse(MenuItem item) {
            if (mSearchVisible) {
                toggleSearch();
            }
            return true;
        }
    });
}
Also used : MenuItemCompat(android.support.v4.view.MenuItemCompat) SearchView(android.support.v7.widget.SearchView) MenuItem(android.view.MenuItem)

Example 87 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)

Example 88 with SearchView

use of android.support.v7.widget.SearchView in project dagger-test-example by aschattney.

the class MainActivity method onCreateOptionsMenu.

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.menu_main, menu);
    MenuItem searchMenuItem = menu.findItem(R.id.action_search);
    SearchView searchView = (SearchView) searchMenuItem.getActionView();
    this.searchViewObservable(searchView).distinctUntilChanged().debounce(1000, TimeUnit.MILLISECONDS).observeOn(androidScheduler).doOnNext(disposable -> mViewPager.setCurrentItem(SectionsPagerAdapter.POSITION_SEARCH, true)).doOnNext(s -> searchView.clearFocus()).subscribeWith(searchSubject);
    return true;
}
Also used : RxScheduler(dagger.extension.example.di.qualifier.RxScheduler) Bundle(android.os.Bundle) ButterKnife(butterknife.ButterKnife) SearchView(android.support.v7.widget.SearchView) ViewPager(android.support.v4.view.ViewPager) Intent(android.content.Intent) NonNull(android.support.annotation.NonNull) MenuItem(android.view.MenuItem) BindView(butterknife.BindView) TabLayout(android.support.design.widget.TabLayout) Inject(javax.inject.Inject) Scheduler(io.reactivex.Scheduler) Menu(android.view.Menu) MAIN(dagger.extension.example.di.qualifier.RxScheduler.Type.MAIN) Observable(io.reactivex.Observable) R(dagger.extension.example.R) RxObservable(dagger.extension.example.di.qualifier.RxObservable) NavigationController(dagger.extension.example.service.NavigationController) PermissionResult(dagger.extension.example.service.PermissionResult) PermissionService(dagger.extension.example.service.PermissionService) ObservableEmitter(io.reactivex.ObservableEmitter) SEARCH(dagger.extension.example.di.qualifier.RxObservable.Type.SEARCH) TimeUnit(java.util.concurrent.TimeUnit) LocationService(dagger.extension.example.service.LocationService) PAGE(dagger.extension.example.di.qualifier.RxObservable.Type.PAGE) Toolbar(android.support.v7.widget.Toolbar) PublishSubject(io.reactivex.subjects.PublishSubject) DaggerAppCompatActivity(dagger.android.support.DaggerAppCompatActivity) SearchView(android.support.v7.widget.SearchView) MenuItem(android.view.MenuItem)

Example 89 with SearchView

use of android.support.v7.widget.SearchView in project Varis-Android by dkhmelenko.

the class MainActivity method onCreateOptionsMenu.

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater menuInflater = getMenuInflater();
    menuInflater.inflate(R.menu.menu_main, menu);
    MenuItem searchItem = menu.findItem(R.id.action_search);
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    mSearchView = null;
    if (searchItem != null) {
        mSearchView = (SearchView) searchItem.getActionView();
    }
    if (mSearchView != null) {
        mSearchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
        mSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {

            @Override
            public boolean onQueryTextSubmit(String query) {
                boolean submitProhibited = true;
                if (query.length() > SEARCH_LIMIT) {
                    // save search query to history
                    SearchRecentSuggestions suggestionsProvider = new SearchRecentSuggestions(MainActivity.this, SearchHistoryProvider.AUTHORITY, SearchHistoryProvider.MODE);
                    suggestionsProvider.saveRecentQuery(query, null);
                    submitProhibited = false;
                }
                return submitProhibited;
            }

            @Override
            public boolean onQueryTextChange(String newText) {
                reloadSearchHistoryAdapter(newText);
                return true;
            }
        });
        mSearchView.setOnSuggestionListener(new SearchView.OnSuggestionListener() {

            @Override
            public boolean onSuggestionClick(int position) {
                mSearchView.setQuery(mQueryItems.get(position), true);
                return true;
            }

            @Override
            public boolean onSuggestionSelect(int position) {
                return true;
            }
        });
        reloadSearchHistoryAdapter("");
        // restore query if it was
        if (!TextUtils.isEmpty(mSavedQuery)) {
            mSearchView.setQuery(mSavedQuery, false);
            mSearchView.setIconified(false);
        }
    }
    return super.onCreateOptionsMenu(menu);
}
Also used : SearchView(android.support.v7.widget.SearchView) MenuInflater(android.view.MenuInflater) SearchManager(android.app.SearchManager) MenuItem(android.view.MenuItem) SearchRecentSuggestions(android.provider.SearchRecentSuggestions)

Example 90 with SearchView

use of android.support.v7.widget.SearchView in project SharedPreferenceInspector by PrashamTrivedi.

the class SharedPreferencesItem method onOptionsItemSelected.

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();
    if (id == R.id.action_testmode) {
        getActivity().supportInvalidateOptionsMenu();
        changeTestMode();
    }
    if (id == R.id.action_search) {
        SearchView searchView = (SearchView) MenuItemCompat.getActionView(item);
        if (searchView != null) {
            searchView.setQueryHint(getString(R.string.searchHint));
            searchView.setOnQueryTextListener(new OnQueryTextListener() {

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

                @Override
                public boolean onQueryTextChange(String s) {
                    search(s);
                    return true;
                }
            });
        }
    }
    return super.onOptionsItemSelected(item);
}
Also used : OnQueryTextListener(android.support.v7.widget.SearchView.OnQueryTextListener) 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