You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This isn't a bug with this code, but I'm throwing it out there as a potential gotcha that I only ran into after implementing the dismiss/swap functionality from this demo.
After a dismiss or swap of items in a recycler view, "holder.getAdapterPosition()" will return NO_POSITION (-1) if you've called "notifyDataSetChanged()" since the last layout pass. I was passing getAdapterPosition() to my Activity in response to some user interaction, which had always worked previously. After either of the actions above, the adapter position became invalid until an orientation change or attempt to scroll the screen. Using getLayoutPosition() in place of getAdapterPosition() resolved the issue.
The text was updated successfully, but these errors were encountered:
This isn't a bug with this code, but I'm throwing it out there as a potential gotcha that I only ran into after implementing the dismiss/swap functionality from this demo.
After a dismiss or swap of items in a recycler view, "holder.getAdapterPosition()" will return NO_POSITION (-1) if you've called "notifyDataSetChanged()" since the last layout pass. I was passing getAdapterPosition() to my Activity in response to some user interaction, which had always worked previously. After either of the actions above, the adapter position became invalid until an orientation change or attempt to scroll the screen. Using getLayoutPosition() in place of getAdapterPosition() resolved the issue.
The text was updated successfully, but these errors were encountered: