android current position - Get visible items in RecyclerView
Finally, I founded a solution for know if the current item is visible, from the onBindViewHolder event in the adapter.
The key is the method isViewPartiallyVisible from LayoutManager.
In your adapter, you can get de LayoutManager from the recyclerView, which you can get from the onAttachedToRecyclerView event.
StaggeredGridLayoutManager do this:
RecyclerView rv = findViewById(...); StaggeredGridLayoutManager lm = new StaggeredGridLayoutManager(...); rv.setLayoutManager(lm);
And to get visible item views:
int viewsIds = lm.findFirstCompletelyVisibleItemPositions(null); ViewHolder firstViewHolder = rvPlantios.findViewHolderForLayoutPosition(viewsIds); View itemView = viewHolder.itemView;
Remember to check if it is empty.