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;
}
});
}
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);
}
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;
}
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);
}
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);
}
Aggregations