Skip to content

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

@vraj-s-shah

Description

@vraj-s-shah

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions