Crash in case if list scrolled to bottom and new adapter set with less data
GoogleCodeExporter opened this issue · comments
Google Code Exporter commented
Steps to reproduce:
1) Set adapter to amazing list view with 30 elements.
2) Scroll list to bottom.
3) Set adapter to amazing list viwe with 10 elements.
4) Crash.
The reason:
AbsListView (which is base class for ListView and thus AmazingListView) in
method setOnScrollListener calls onScroll method of the listener.
AmazingListAdapter itself is the scroll listener. If at the time of setting
listener count of items in list will be more than in adapter, scroll listener
(which is adapter) gets index which is out of bounds, which causes it to crash.
This situation currently is possible because in AmazingListView.setAdapter
setting adapter is performed after setting scroll listener, so, at the time
scroll listener is set, there is old adapter (with old data) in the ListView.
I have attached the patch to fix this problem.
Original issue reported on code.google.com by some.any...@gmail.com
on 27 Nov 2013 at 7:38
Attachments: