SwipeLayout
SwipeLayout copied to clipboard
Setting setEnabledSwipe(false) from adapter is not actually disabling the swipe
I have some conditions where I just want specific users to get the swipe functionality but somehow it is enabling swipe for everyone
(binding as? ItemRoomMemberBinding)?.apply {
if (!isSwipeEnabled || loggedInUserId == data.userId) {
swipeLayout.isEnabledSwipe = false
return
}
swipeLayout.setOnActionsListener(object : SwipeLayout.SwipeActionsListener {
override fun onOpen(direction: Int, isContinuous: Boolean) {
currentlyOpenedSwipeLayout?.close(true)
currentlyOpenedSwipeLayout = swipeLayout
}
override fun onClose() {
//NO-OP
}
})
ivAddMember.setOnClickListener {
swipeLayout.close(true)
}
ivRemoveMember.setOnClickListener {
swipeLayout.close(true)
}
}
Here isSwipeEnabled is set from outside based on some condition. Even if I pass false to isSwipeEnabled and let the code swipeLayout.isEnabledSwipe = false
run, it still let the user swipe instead of disabling.