daimajia / AndroidSwipeLayout

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

How can i hold status of swipelayout in my ViewHolder? #177

Open chiennt56 opened 9 years ago

chiennt56 commented 9 years ago

I want to hold status of swipelayout (open/close) when scrolling the list in recyclerView. So, how can i do it?

IlyaEremin commented 9 years ago

Simplest solution: store status into model. Then restore state while drawing. If you won't tie model with your view then store status in some "storage". For example in Map<ModelId, ViewState>. But it cause memory allocation while drawing and it is not very good for performance.

chiennt56 commented 9 years ago

@IlyaEremin Thank you, llyaEremin. I tried that way. But it wasn't work, because i couldn't catch a event fired from swipelayout to set boolean attribute into model when i swipe a item of RecyclerView. I tried to use addSwipeListener method but it didn't work normally as i want.

danvass commented 9 years ago

I'm trying to do the same, have you managed to find a solution @chiennt56?

abhishekagra commented 8 years ago

@chiennt56 Have you find out the solution? I am also facing the same issue.

donlingliang commented 7 years ago

@chiennt56 I bet chiennt56 is saying using a wrapper to wrap your current model and the state, and each time bindViewHolder is getting called, just check the boolean