-
Notifications
You must be signed in to change notification settings - Fork 79
VideoListDemoActivity - Immediate notifyDataSetChanged #2
Comments
My initial diagnosis of notifyDataSetChanged being called too soon was close. I had introduced a check to see if a view was being reused in the list for a different thumbnail. This occasionally led me to call "thumbnail.initialize" on a view that was being initialised. I believe this is where the error originates from. Avoiding this check has stopped the crash. |
Thanks this helped me a lot, introducing a simple check solved my issues |
Could anyone please post a sample code for the fix or elaborate on it. Sadly, this discussion leads me nowhere. Thanks. |
I have the same problem In the adapter I put like this:
It is works for me... |
@parasjain1 ... i agreed with you...
|
@rudiw wow great solution it worked for me !! |
When I use this solution, the initialize method is called for particular positions only. For example, I have three items per page, when I load that in the recycler view, the initialize method is called only for the 0 position. After pagination, another 3 items received, in that the initialize method is called only for 4 and 5 positions. The initialize method is not called for 1,2 and 3 positions. So, please suggest a solution that works in this scenario. |
Perhaps private boolean readyForLoadingYoutubeThumbnail = true; |
I have included a slight variation of the example code from VideoListDemoActivity in my app. In my case, VideoListFragment is initialised with some cached content, and simultaneously a request is made to update to the latest set of videos. This can come back relatively quickly, whilst the cached video thumbnails are still in some form of loading state (Usually "1) The view has not yet been created"). When the new data is returned, I call notifyDataSetChanged on the adapter. Sometimes this will cause an IllegalStateException:
I have managed to reproduce this consistently in my version. If I stop the notifyDataSetChanged, or even delay it by 0.5 seconds, there is no crash. Can you reproduce this too? Any suggestions what I should do in this case?
Thanks,
Jon.
The text was updated successfully, but these errors were encountered: