Since I addData, and called the notifyDataSetChanged(), then I use the findLastCompletelyVisibleItemPosition method immediately, the result is not correct.then I use a postDelay, it's result become correct, why can this be? And how can i know whether the data added completely?
Asked
Active
Viewed 1,186 times
-4
-
this is because the real job is done not in `notifyDataSetChanged` - this is just used to notify, you dont have to use `postDelayed`, use simple `post` instead – pskink Nov 25 '16 at 05:47
-
@pskink How were you able to find any error in this?! This is just text with (for me) seemingly random commands thrown in... Respect for that! – geisterfurz007 Nov 25 '16 at 07:43
-
Still incredible. It is hard for me to understand source (without beeing formatted). – geisterfurz007 Nov 25 '16 at 08:00
-
@pskink post sometimes not correct too, I've tested for several times – tysheng Nov 25 '16 at 10:34
1 Answers
0
Before adding the data to list, save Last visible position to a variable then add data to list and call notifyDataSetChanged(), then scroll the recyclerview to stored position

Sachin
- 107
- 1
- 6
-
I get the data from net the first time, and I want to know if it is full page, but seems the visible item calculate is not immediate. – tysheng Nov 25 '16 at 10:41
-
nothing special, just add data(empty at the beginning), notify and findLastCompletelyVisibleItemPosition, but my item bean is a little complex, I think this may be the reason? – tysheng Nov 29 '16 at 00:49