Reputation: 212
I have following structure: ViewPager -> 3 pages, each same with CoordinatorLayout containing single child RecyclerView. Adapter bonded with https://github.com/evant/binding-collection-adapter ReyclerView has attached ItemTouchHelper for swipe detection on list elements.
Used ViewPager is customized by overwriting onInterceptTouchEvent(return false) and onTouchEvent(return false)
When ViewPager has single page added - swipe works without issues When ViewPager has more than one page - swiping between pages is disabled as desired, but RecyclerView seems to not receive swipe event
I was trying already in method onInterceptTouchEvent pass events to RecyclerView by searching him by tag (it was found successfully) by any available method (interceptTouch, dispatchTouch, onTouch) passing MotionEvent from viewPager. None of such method worked :(
How to pass swipe event to RecyclerView items? I don't need for ViewPager any swiping, just clickable tabs from TabLayout (it is working already properly). I need just to intercept swipe event to be catched by Touch helper listener for RecyclerView items
Upvotes: 0
Views: 34
Reputation: 212
Ok, seems that core issue was different than I thought. So if you have ViewPager containing pages with RecyclerView and you want swipe action on each of it using ItemTouchHelper you must use separate instance for each page.
Reason for that is ItemTouchHelper while attaching to RecyclerView is removing callbacks from previously stored in variable RecyclerView. So when having 3 pages sth like that is happening:
As result only third page have swipe action (as its RecyclerView have touchCallbacks)
Upvotes: 0