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