etsy / AndroidStaggeredGrid

An Android staggered grid view which supports multiple columns with rows of varying sizes.
https://github.com/etsy/AndroidStaggeredGrid
4.76k stars 1.13k forks source link

getView() in adapter called with delay #112

Open Bystysz opened 10 years ago

Bystysz commented 10 years ago

Hello First I would like to thank you for preparing such a great library. Unfortunately I have found one bug. It is probably connected with a bug #107, but I am not sure, so I decided to create a new topic. Under this URL: https://www.youtube.com/watch?v=UN-ASRymh4o there is a video, which I prepared to better explain you a bug.

Description: In your sample on Github in StaggeredGridActivity.java class you create 30 tiles. When a user scrolls down to the last item, you start loading more tiles (another 30). I've found that after loading more tiles, when a user scrolls up to i.e. 25th tile and again scrolls down to a 30th tile, the next tiles will be visible after a delay. It seems like only when a group of new tiles (from those which have been loaded) must been in a visible area to show all of them. In a situation presented in video I had loaded more than 30 tiles.

What's more this bug occurs only when your library has to show new, loaded tiles and after calling notifyDataSetChanged() to an adapter.

I hope this bug is not difficult and you will fix it or maybe you could give me some advice to avoid this bug.

Łukasz

mjsherman commented 10 years ago

I am seeing the same issue in a production app. I'll try digging through to find a resolution, but I'm not terribly familiar with the internals of the library.

A reproducible example of the bug can be created by following these steps: 1) Change SAMPLE_DATA_ITEM_COUNT in SampleData to 10 (from 30) 2) In SampleAdapter, add: mRandom.setSeed(1); immediately after creating mRandom 3) Run and open the sample to "Staggered Grid View" 4) Choose "3 Columns" 5) Scroll down until position 20 should be visible (middle column, below position 16).

Expected behavior: item 20 is visible once there is space below item 16 Actual Behavior: item 20 is not loaded until there is space below item 19, at which point both items 20 and 21 are immediately loaded/displayed.