Export to GitHub

android-amazing-listview - issue #7

Crash in case if list scrolled to bottom and new adapter set with less data


Posted on Nov 27, 2013 by Swift Bear

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.

Attachments

Status: New

Labels:
Type-Defect Priority-Medium