daimajia / AndroidSwipeLayout

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

Hello #546

Open UmairAhmed420 opened 4 years ago

UmairAhmed420 commented 4 years ago

is there a way to check if one swipe is already open then before opening 2nd swipe first swipe gets close

sheckspir commented 4 years ago

SwipeLayout is just a ViewGroup. So it shouldn't know about other views. You can resolve that logic by yourself For example, if you use RececlerView with many items(viewed by SwipeLayout) you can ask each SwipeLayout is it opened or closed and do your logic:

var closed = 0
for (i in 0..recyclerView.childCount) {
    val view = recyclerView.getChildAt(i)
    if (view is SwipeLayout) {
        if (view.openStatus == SwipeLayout.Status.Open)  {
            closed++
            view.close()
        }
    }
}
Toast.makeText(context, "We closed $closed items", Toast.LENGTH_SHORT).show()

I'm not sure about how resolve situation with Status.Middle in right way