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

Fix item place error when load more #164

Open YellowEyed opened 9 years ago

YellowEyed commented 9 years ago

When I use this StaggeredGridView, I add a footer view to show when loading more data from server. When load complete, the items placed like this: screenshot_2014-12-23-14-34-23 the last item should place at right side, but it came to left side. So I check the code, find out the problem is like this: before load more, I have 20 items and a footer in this view, that's total 21 items. The footer's position is 20. So when I load more from server, there is only one item loaded from server and added to the view, and it's position is 20, the GridItemRecord at position 20 exist, it's a footer, and it's column is 0 due to uninitialized. So the item is placed at left side(column 0).

YellowEyed commented 9 years ago

The second commit is about a problem of clicking item not reponse. And here is the situation: I have two headers, the first one is selectable, and the second one is not. In this situation, click the second item currently attach in the StaggeredGridView has no response. The problem lies at this code mAdapter.isEnabled(motionPosition). motionPosition means the position of the item currently attached in the StaggeredGridView, not the position of the item in the adapter's data list, so it should be like this mAdapter.isEnabled(motionPosition + mFirstPosition).

YellowEyed commented 9 years ago

The third commit is when I have a height changable footer, and I slide to the bottom and continue sliding up, the footer's height changes. And if the item with heigher bottom, pass the top edge of the view, it will be removed from this view. But it will be redrawn right away with bottom at the footer's top edge. So I change it to not remove the last second item.