bauerca / drag-sort-listview

Android ListView with drag and drop reordering.
3.2k stars 1.44k forks source link

Make AdapterWrapper extend BaseAdapter #81

Closed scompt closed 11 years ago

scompt commented 11 years ago

Enabling fast scrolling on a DragSortListView will result in an exception:

Reason: java.lang.ClassCastException: com.mobeta.android.dslv.DragSortListView$AdapterWrapper cannot be cast to android.widget.BaseAdapter

The FastScroller is expecting the list adapter to be an instance of BaseAdapter, which isn't the case because the DragSortListView wraps it in the inner AdapterWrapper class, which extends HeaderViewListAdapter, which itself isn't related to BaseAdapter. From what I can tell, this was only done because it handles some of the delegation to the wrapped class; the header/footer behavior that it also provides isn't used.

This pull request refactors AdapterWrapper to extends BaseAdapter by changing the class definition and delegating all of the necessary methods. It's loosely based on the AdapterWrapper from @commonsguy. An alternative might be to include the cwac-adapter project as a dependency and extend from AdapterWrapper.

scompt commented 11 years ago

That all being said, I don't use headers/footers in my app. All I can say is that it compiles and works for my use case.

bauerca commented 11 years ago

Thanks for finding this.

daneren2005 commented 11 years ago

I was just googling for a solution to this issue and as well as references to how it was fixed in similar libraries I came across this. Thanks for already having a fix for this :D