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

Multiple rows opened despite setMode(Attributes.Mode.Single); call #162

Open
bradroid opened this issue Jun 2, 2015 · 1 comment
Open

Comments

@bradroid
Copy link

bradroid commented Jun 2, 2015

This bug can be reproduced in the demo application.
Steps to reproduce:

  1. Open AndroidSwipeLayout demo app
  2. Open RecyclerView demo
  3. Delete item number 6 (Colorado)
  4. Delete item number 6 (Connecticut)
  5. Delete item number 6 (Delaware)
  6. You are now able to open both California and Florida (items 5 and 6) at the same time, even thought Mode.Single is set. Also, this is possible only if you open Florida first 😕
    EDIT: Actually, the bugged items in this case are: Florida, Georgia and Hawaii (6,7,8). You are able to keep these 3 items opened + any other item at the same time.
@bradroid
Copy link
Author

bradroid commented Jun 2, 2015

I checked your delete item implementation in the demo, within recycler view adapter:

 viewHolder.buttonDelete.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mItemManger.removeShownLayouts(viewHolder.swipeLayout);
                mDataset.remove(position);
                notifyItemRemoved(position);
                notifyItemRangeChanged(position, mDataset.size());
                mItemManger.closeAllItems();
                Toast.makeText(view.getContext(), "Deleted " + viewHolder.textViewData.getText().toString() + "!", Toast.LENGTH_SHORT).show();
            }

I think the problem is in calling this line:
mItemManger.removeShownLayouts(viewHolder.swipeLayout);

What this does is it removes the layout from item manager, which sounds logical at first because item is deleted, but this very layout is used for view recycling - so the item manager will ignore not just the deleted item, but all the items that got recycled using it's layout. Hope this makes sense.

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

1 participant