MultiChoiceRecyclerView icon indicating copy to clipboard operation
MultiChoiceRecyclerView copied to clipboard

selectAll() selects only visible items.

Open waleedaftab opened this issue 8 years ago • 3 comments

Whenever selectAll() is called and recyclerview hasn't been scrolled down only visible items are select and count of selected items is also not equal to all items.

   private void setUpMultiChoiceRecyclerView() {
        MultiChoiceToolbar multiChoiceToolbar =
                new MultiChoiceToolbar.Builder(MainActivity.this, appToolbar)
                        .setTitles(getString(toolbarTitle() ), "")
                        .build();
        folderAdapter.setMultiChoiceToolbar(multiChoiceToolbar);
        folderAdapter.setMultiChoiceSelectionListener(new MultiChoiceAdapter.Listener() {
            @Override
            public void OnItemSelected(int selectedPosition, int itemSelectedCount, int allItemCount) {
                bottomBarRecyclerView.setVisibility(View.VISIBLE);
                if (itemSelectedCount > 1) {
                }
            }
    
       @Override
            public void OnItemDeselected(int deselectedPosition, int itemSelectedCount, int allItemCount) {
                if (itemSelectedCount == 0) {
                    bottomBarRecyclerView.setVisibility(View.GONE);
                }
            }

            @Override
            public void OnSelectAll(int itemSelectedCount, int allItemCount) {
                 for(int i=0;i<allItemCount;i++){
                    folderAdapter.select(i);
                }
                folderAdapter.notifyDataSetChanged();
            }

            @Override
            public void OnDeselectAll(int itemSelectedCount, int allItemCount) {
                bottomBarRecyclerView.setVisibility(View.GONE);
            }
        });
    }

I have even tried to select individual elements in callback of onSelectAll(). Thanks.

waleedaftab avatar Apr 21 '18 12:04 waleedaftab

I've just tried, without scrolling, calling the selectAll() and getSelectedItemCount() method it seems like all the items are selected. Can you please be more specific, add some logs or steps to reproduce. Thanks

dvdciri avatar May 13 '18 18:05 dvdciri

I have this problem too.

When ever calling selectAll() only the views already loaded in the the recyclerview is selected, not the whole dataset.

Scrolling down after using selectAll(), new items loaded into the recyclerview from the dataset are not selected.

aldasa avatar May 14 '18 09:05 aldasa

This happens only when you setup multichoice recyclerview with empty list and add elements to the list later on and notify adapter. If you setup it already populated data list, it works fine.

waleedaftab avatar May 27 '18 23:05 waleedaftab