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?