0

I have a RecyclerView with a GridLayoutManager with video streams in each grid cell. I need some kind of callback for visibility on each cell to know when to stop the video in the cells that are not visible on screen and start the videos on the cells that are visible.

I've experimented with RecyclerView.OnScrollListener to then use findFirstCompletelyVisibleItemPosition and findLastCompletelyVisibleItemPosition to get the range of visible items. But I haven't found a way to find the items that have moved out of screen.

Is there a way to obtain all the hidden and visible items from the RecyclerView or RecyclerView.Adapter or GridLayoutManager? Or is there a way for the RecyclerView.ViewHolder to listen for changes in its hidden/visible state to stop the video?

Lalle
  • 676
  • 12
  • 30
  • 1
    Maybe this helps https://stackoverflow.com/questions/24989218/get-visible-items-in-recyclerview – Héctor Oct 31 '17 at 11:09
  • Not that much as I've explained in my post – Lalle Oct 31 '17 at 13:30
  • The core part of your question may be a duplicate https://stackoverflow.com/questions/32678632/is-there-a-callback-for-when-recyclerview-has-finished-showing-its-items-after-i – Emad Razavi Mar 07 '20 at 07:20

0 Answers0