I created a RecyclerView with "swap item positions" and "remove item with swipe gesture" as explained here. Everything works fine except for a seek bar which is contained in the items. I can only adjust the seekbar value by tapping on some spot but not changing the value by tapping on the draggable thumb and then moving it left or right. What happens in those cases is that the swipe gesture removes the item from the parent RecyclerView.
How can I achieve to change the value of the seekbar when a swipe gesture occurs on it and only remove it when a swipe gesture is performed outside the seekbar?
@Ben P.: I created my own class that extends from LinearLayout, implemented the onInterceptTouchEvent
but I was not able to interrupt the swipe gesture. I guess because I would have needed to intercept the RecyclerView method, however, this class does not provide an onInterceptTouchEvent
method which could be overridden.
Instead, I solved my problem as follows: I have two types of views I display in the RecyclerView (default and edit) and only the edit type contains a SeekBar. As it is absolutely okay to not allow to remove the currently-edited item, I distuingished the type of the ViewHolder in the getMovementFlags
method which I override from ItemTouchHelper.Callback()
.
(Sorry that I didn't mention the piece of information with the two view types.)