com.arlib.floatingsearchview.suggestions.model.SearchSuggestion Java Examples
The following examples show how to use
com.arlib.floatingsearchview.suggestions.model.SearchSuggestion.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FloatingSearchView.java From floatingsearchview with Apache License 2.0 | 6 votes |
private void swapSuggestions(final List<? extends SearchSuggestion> newSearchSuggestions, final boolean withAnim) { mSuggestionsList.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { Util.removeGlobalLayoutObserver(mSuggestionsList, this); boolean isSuggestionItemsFillRecyclerView = updateSuggestionsSectionHeight(newSearchSuggestions, withAnim); //we only need to employ the reverse layout technique if the items don't fill up the RecyclerView LinearLayoutManager suggestionsListLm = (LinearLayoutManager) mSuggestionsList.getLayoutManager(); if (isSuggestionItemsFillRecyclerView) { suggestionsListLm.setReverseLayout(false); } else { mSuggestionsAdapter.reverseList(); suggestionsListLm.setReverseLayout(true); } mSuggestionsList.setAlpha(1); } }); mSuggestionsList.setAdapter(mSuggestionsAdapter);//workaround to avoid list retaining scroll pos mSuggestionsList.setAlpha(0); mSuggestionsAdapter.swapData(newSearchSuggestions); mDivider.setVisibility(!newSearchSuggestions.isEmpty() ? View.VISIBLE : View.GONE); }
Example #2
Source File: SearchSuggestionsAdapter.java From floatingsearchview with Apache License 2.0 | 5 votes |
@Override public void onBindViewHolder(RecyclerView.ViewHolder vh, int position) { SearchSuggestionViewHolder viewHolder = (SearchSuggestionViewHolder) vh; if (!mShowRightMoveUpBtn) { viewHolder.rightIcon.setEnabled(false); viewHolder.rightIcon.setVisibility(View.INVISIBLE); } else { viewHolder.rightIcon.setEnabled(true); viewHolder.rightIcon.setVisibility(View.VISIBLE); } SearchSuggestion suggestionItem = mSearchSuggestions.get(position); viewHolder.body.setText(suggestionItem.getBody()); if(mTextColor != -1){ viewHolder.body.setTextColor(mTextColor); } if(mRightIconColor != -1){ Util.setIconColor(viewHolder.rightIcon, mRightIconColor); } if (mOnBindSuggestionCallback != null) { mOnBindSuggestionCallback.onBindSuggestion(viewHolder.itemView, viewHolder.leftIcon, viewHolder.body, suggestionItem, position); } }
Example #3
Source File: FloatingSearchView.java From floatingsearchview with Apache License 2.0 | 5 votes |
private int calculateSuggestionItemsHeight(List<? extends SearchSuggestion> suggestions, int max) { //todo // 'i < suggestions.size()' in the below 'for' seems unneeded, investigate if there is a use for it. int visibleItemsHeight = 0; for (int i = 0; i < suggestions.size() && i < mSuggestionsList.getChildCount(); i++) { visibleItemsHeight += mSuggestionsList.getChildAt(i).getHeight(); if (visibleItemsHeight > max) { visibleItemsHeight = max; break; } } return visibleItemsHeight; }
Example #4
Source File: SearchActivity.java From POCenter with MIT License | 4 votes |
/** * set listeners */ private void initEvent() { // refresh listener bind.vContent.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { loadData(true); } }); // load more listener searchAdapter.setOnLoadMoreListener(new BaseQuickAdapter.RequestLoadMoreListener() { @Override public void onLoadMoreRequested() { bind.rv.post(new Runnable() { @Override public void run() { loadMore(); } }); } }); // item click listener bind.rv.addOnItemTouchListener(new OnItemClickListener() { @Override public void SimpleOnItemClick(BaseQuickAdapter baseQuickAdapter, View view, int i) { // get item url ProjectBean project = (ProjectBean) baseQuickAdapter.getItem(i); // start detail activity Intent intent = new Intent(SearchActivity.this, DetailActivity.class); intent.putExtra(DetailActivity.EXTRA_URL, project.url); intent.putExtra(DetailActivity.EXTRA_TITLE, project.title); intent.putExtra(DetailActivity.EXTRA_DESCRIPTION, project.description); startActivity(intent); } }); // search listener bind.fsv.setOnSearchListener(new FloatingSearchView.OnSearchListener() { @Override public void onSuggestionClicked(SearchSuggestion searchSuggestion) { } @Override public void onSearchAction(String currentQuery) { if (!TextUtils.isEmpty(currentQuery)) { presenter.setSearchString(currentQuery); loadData(false); } } }); }
Example #5
Source File: SearchSuggestionsAdapter.java From floatingsearchview with Apache License 2.0 | 4 votes |
void onBindSuggestion(View suggestionView, ImageView leftIcon, TextView textView, SearchSuggestion item, int itemPosition);
Example #6
Source File: SearchSuggestionsAdapter.java From floatingsearchview with Apache License 2.0 | 4 votes |
public void swapData(List<? extends SearchSuggestion> searchSuggestions) { mSearchSuggestions = searchSuggestions; notifyDataSetChanged(); }
Example #7
Source File: SearchSuggestionsAdapter.java From floatingsearchview with Apache License 2.0 | 4 votes |
public List<? extends SearchSuggestion> getDataSet() { return mSearchSuggestions; }
Example #8
Source File: FloatingSearchView.java From floatingsearchview with Apache License 2.0 | 2 votes |
/** * Called when a suggestion was clicked indicating * that the current search has completed. * * @param searchSuggestion */ void onSuggestionClicked(SearchSuggestion searchSuggestion);
Example #9
Source File: FloatingSearchView.java From floatingsearchview with Apache License 2.0 | 2 votes |
/** * Clears the current suggestions and replaces it * with the provided list of new suggestions. * * @param newSearchSuggestions a list containing the new suggestions */ public void swapSuggestions(final List<? extends SearchSuggestion> newSearchSuggestions) { swapSuggestions(newSearchSuggestions, true); }
Example #10
Source File: FloatingSearchView.java From floatingsearchview with Apache License 2.0 | 2 votes |
/** * Collapses the suggestions list and * then clears its suggestion items. */ public void clearSuggestions() { swapSuggestions(new ArrayList<SearchSuggestion>()); }
Example #11
Source File: SearchSuggestionsAdapter.java From floatingsearchview with Apache License 2.0 | votes |
void onItemSelected(SearchSuggestion item);
Example #12
Source File: SearchSuggestionsAdapter.java From floatingsearchview with Apache License 2.0 | votes |
void onMoveItemToSearchClicked(SearchSuggestion item);