use of com.lapism.searchview.view.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 com.lapism.searchview.view.SearchView in project AisenWeiBo by wangdan.
the class SearchFragment method setupSearchView.
private void setupSearchView() {
// SearchView basic attributes ------------------------------------------------------------
int mVersion = SearchCodes.VERSION_MENU_ITEM;
int mStyle = SearchCodes.STYLE_MENU_ITEM_CLASSIC;
int mTheme = SearchCodes.THEME_LIGHT;
mSearchView.setVersion(mVersion);
mSearchView.setStyle(mStyle);
mSearchView.setTheme(mTheme);
mSearchView.setDivider(false);
mSearchView.setHint(R.string.search_hint);
mSearchView.setHintSize(getResources().getDimension(R.dimen.search_text_medium));
mSearchView.setVoice(false);
mSearchView.setAnimationDuration(300);
mSearchView.setShadowColor(ContextCompat.getColor(getActivity(), R.color.background_dim_overlay));
mSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
if (!TextUtils.isEmpty(query)) {
onQuery(query);
}
return true;
}
@Override
public boolean onQueryTextChange(String newText) {
if (suggestList != null && searchAdapter != null)
onQuerySuggestChange(newText);
return true;
}
});
mSearchView.setOnSearchViewListener(new SearchView.SearchViewListener() {
@Override
public void onSearchViewShown() {
}
@Override
public void onSearchViewClosed() {
if (getSwipeRefreshLayout().getVisibility() == View.VISIBLE) {
getSwipeRefreshLayout().setVisibility(View.GONE);
}
getActivity().finish();
getActivity().overridePendingTransition(0, 0);
}
});
try {
Field editField = SearchView.class.getDeclaredField("mEditText");
editField.setAccessible(true);
editSearch = (EditText) editField.get(mSearchView);
editSearch.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
}
});
Field shadowField = SearchView.class.getDeclaredField("mShadow");
shadowField.setAccessible(true);
shadowView = (View) shadowField.get(mSearchView);
} catch (Exception e) {
e.printStackTrace();
}
suggestList = new ArrayList<>();
// searchAdapter = new SearchAdapter(getActivity(), new ArrayList<SearchItem>(), suggestList, SearchCodes.THEME_LIGHT);
searchAdapter = new SearchsSuggestAdapter(getActivity(), new ArrayList<SearchItem>(), suggestList, SearchCodes.THEME_LIGHT);
searchAdapter.setOnItemClickListener(new SearchAdapter.OnItemClickListener() {
@Override
public void onItemClick(View view, int position) {
if (suggestList.size() > position) {
onQuery(suggestList.get(position).get_text().toString());
editSearch.setText(q);
editSearch.setSelection(q.length());
}
}
});
mSearchView.setAdapter(searchAdapter);
if (!TextUtils.isEmpty(q))
mSearchView.setQuery(q);
mSearchView.show(true);
searchIn();
}
Aggregations