Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

selectAll() selects only visible items. #65

Open
waleedaftab opened this issue Apr 21, 2018 · 3 comments
Open

selectAll() selects only visible items. #65

waleedaftab opened this issue Apr 21, 2018 · 3 comments

Comments

@waleedaftab
Copy link

waleedaftab commented Apr 21, 2018

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.

@dvdciri
Copy link
Owner

dvdciri commented May 13, 2018

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

@aldasa
Copy link

aldasa commented May 14, 2018

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.

@waleedaftab
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants