SwipeLayout icon indicating copy to clipboard operation
SwipeLayout copied to clipboard

Setting setEnabledSwipe(false) from adapter is not actually disabling the swipe

Open vraj-s-shah opened this issue 1 year ago • 0 comments

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.

vraj-s-shah avatar Aug 01 '23 18:08 vraj-s-shah