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