Closed manabreak closed 8 years ago
Do you want to listen to the snap event or just query the snapped item? If it's the first one, there's no support for this yet, but might be interesting to add. If it's the last one, you can use findFirstCompletelyVisibleItemPosition/findLastCompletelyVisibleItemPosition from LinearLayoutManager.
I'm interested in the former one - listening to the snaps. I did manage to use a addOnScrollListener()
and listening for the state changes. More precisely: When the state is SCROLL_STATE_IDLE
, I check whether the layout.findFirstCompletelyVisibleItemPosition()
is greater than -1
. If it is, we have a bound item.
So did you manage to do it?
Yes, using the method I mentioned above. Although it could be a nice addition to implement in the helper itself.
Added in https://github.com/rubensousa/RecyclerViewSnap/commit/7e0e1687e8322bd232e53e2c04861ca286eb24b7.
Will be out in 1.0, after google releases the fix for: https://code.google.com/p/android/issues/detail?id=223649
1.0 released :)
I'm trying to do a snappy recycler view and your code works perfectly for that. However, I'm trying to figure out how to get the index of the item that was snapped. I proxied the
findTargetSnapPosition
method, but it tends to return -1 quite often.Any idea how to fetch the position, preferably by listening to the snap helper?