SwipeListener calls onOpen callback multiple times
I have two ConstraintLayouts inside Swipelayout. If I keep dragging SurfaceView after the whole BottomView is revealed, the swipelisteners onOpen callback is triggered multiple times.
@Dropppan Happens to me as well
@Dropppan @itaispector any fixes? Happens to me as well
Hey Guys, I have just faced the same problem and found a solution that may work for you too.
If you are using swipeLayout in RecyclerView and doing swipeLayout.addSwipeListener in onBindViewHolder(), move it to constructor of your RecyclerView.ViewHolder implementation.
The causes of the problem: swipeLayout.addSwipeListener does not set new listener but instead adds one to the internal collection. onBindViewHolder() method is invoked every time you scroll the list. So every time the list is scrolled, onBindViewHolder() is executed and adds a new instance of SwipeListener. To prevent this, simply add listener once when new holder is created and never change it.
It looks like it's not actually a bug, but misleading example of usage. Hope this helps.