0

In the application there is a recycleview which contains many blocks.

when the user stop watching (focusing) on specific cell, I have to send value to server.

I can set timer in OnBindView but when I have to stop the timer (the cell is not visible anymore because the user slide the reycleView).? OnViewRecycle callback is not called accurately when the cell is not visible (I mean the cells that are adjacent for the current visible cell).

oschlueter
  • 2,596
  • 1
  • 23
  • 46
Soubhi M. Hadri
  • 133
  • 1
  • 15

2 Answers2

0

check this answer:

https://stackoverflow.com/a/25053500/2318843

you can add ScrollListener addOnScrollListener(OnScrollListener) and then checking changes of visible items if you using LinearLayoutManager or GridLayoutManager with those methods

 int findFirstCompletelyVisibleItemPosition();
 int findLastCompletelyVisibleItemPosition(); 
Community
  • 1
  • 1
RadekJ
  • 2,835
  • 1
  • 19
  • 25
0

You can use the methods recyclerView as

onViewAttachedToWindow(viewHolder)
onViewDetachedFromWindow(viewHodler)

And for example, in method onViewDetachedFromWindow you can stop timer