daimajia / AndroidSwipeLayout

The Most Powerful Swipe Layout!
MIT License
12.38k stars 2.67k forks source link

opened when I scroll out of window andback close itself #474

Open gmm932 opened 7 years ago

gmm932 commented 7 years ago

opened when I scroll out of window and back closed itself

pakudinov commented 6 years ago

Bug in SwipeItemMangerImpl.java at Single mode.

Produce:

  1. Open one item (item A).
  2. Fast open other item (item B). Item A will close automatically.
  3. Call notifyDataSetChanged()

Result: Item B will lose open state.

Reason: Item B may open earlier than item A will close. So in line 189 item B will invalidate mOpenPosition var.

Fix: Add if (mOpenPosition == position) in line 188

public void onClose(SwipeLayout layout) { if (mode == Attributes.Mode.Multiple) { mOpenPositions.remove(position); } else if (mOpenPosition == position) { mOpenPosition = INVALID_POSITION; } }