private void showInputControlOptions() { mSingleSelectIcAdapter = new SingleSelectIcAdapter(mInputControlOptions); inputControlsList.setLayoutManager(new LinearLayoutManager(this)); inputControlsList.setAdapter(mSingleSelectIcAdapter); inputControlsList.setHasFixedSize(true); inputControlsList.addOnScrollListener( new RecyclerView.OnScrollListener() { @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager(); int visibleItemCount = recyclerView.getChildCount(); int totalItemCount = recyclerView.getLayoutManager().getItemCount(); int firstVisibleItem = ((LinearLayoutManager) layoutManager).findFirstCompletelyVisibleItemPosition(); if (totalItemCount > 0 && firstVisibleItem + visibleItemCount >= totalItemCount) { mSingleSelectIcAdapter.loadNextItems(); } } }); mSingleSelectIcAdapter.setFilterListener( new FilterableAdapter.FilterListener() { @Override public void onFilterDone() { onFilteringList(); } }); mSingleSelectIcAdapter.setItemSelectListener( new SingleSelectIcAdapter.ItemSelectListener() { @Override public void onItemSelected(int position) { mInputControlOptions.get(mPreviousSelected).setSelected(false); mSingleSelectIcAdapter.updateItem(mPreviousSelected); mInputControlOptions.get(position).setSelected(true); mSingleSelectIcAdapter.updateItem(position); mPreviousSelected = position; isValueChanged = true; } }); }
private void onFilteringList() { emptyText.setVisibility(mSingleSelectIcAdapter.getItemCount() == 0 ? View.VISIBLE : View.GONE); inputControlsList.scrollToPosition(0); }
@Override public boolean onQueryTextChange(String newText) { mSingleSelectIcAdapter.filter(newText); return true; }