ernestoyaquello / DragDropSwipeRecyclerview

Kotlin Android library that extends RecyclerView to support gestures like drag & drop and swipe, among others. It works with vertical, horizontal and grid lists.
Apache License 2.0
954 stars 100 forks source link

Two different recyclers with different ListOrientation objects share removed swipe direction flags #38

Closed vlytvyne closed 4 years ago

vlytvyne commented 4 years ago

I have 2 completely separated recyclers which are in different fragments in ViewPager. When I remove a swipe or drag flag from one of them it is automatically removed in the second which I find confusing.

Fragment 1: recyclerOne.layoutManager = LinearLayoutManager(context!!) recyclerOne.adapter = adapterOne val orientation = DragDropSwipeRecyclerView.ListOrientation.VERTICAL_LIST_WITH_VERTICAL_DRAGGING orientation.removeSwipeDirectionFlag(DragDropSwipeRecyclerView.ListOrientation.DirectionFlag.RIGHT) recyclerOne.orientation = orientation

Fragment 2: recyclerTwo.layoutManager = LinearLayoutManager(context!!) recyclerTwo.adapter = adapterTwo val orientation = DragDropSwipeRecyclerView.ListOrientation.VERTICAL_LIST_WITH_VERTICAL_DRAGGING orientation.removeSwipeDirectionFlag(DragDropSwipeRecyclerView.ListOrientation.DirectionFlag.LEFT) recyclerTwo.orientation = orientation

The above code will make both recyclers unswipable in either directions instead of making then swipable in different directions.

ernestoyaquello commented 4 years ago

I didn't consider the possibility of having several instances when I implemented this, which is why you are experiencing this problem. I will look into it as soon as possible – sorry for the delay in my answer, I have been busy.

ernestoyaquello commented 4 years ago

If you update to the version 0.6.0 of the library, the issue should disappear (as long as you are using an adapter per list).

Please note that you will have to replace list.orientation?.removeSwipeDirectionFlag(...) with list.disableSwipeDirection(...). Also note that this call must be performed after setting the orientation.

Thanks for finding and submitting the bug!