tjerkw / Android-SlideExpandableListView

A better ExpandableListView, with animated expandable views for each list item
Apache License 2.0
1.98k stars 741 forks source link

fixed bug collapse current open View #17

Closed passsy closed 11 years ago

passsy commented 11 years ago

sry, but in my last commit was a little bug

after changing the cursor of a list the recently closed view gets recreated with an open expandable. The open item was still saved.

tjerkw commented 11 years ago

I also remove the cast (SlideExpandableListAdapter)getAdapter() to a member in order to be more typesafe. Also added a null check.

passsy commented 11 years ago

after calling animateCollapse all views are collapsed. I can't call updateExpandable(target, position); to save the expandable state because I don't have the position. But I know that all items are collapsed, so i can clear the viewHeights and the enableFor mehtod which styles the view items doesn't find a height in line 124.

think, what would happen if viewHeights doesn't get cleard.

First you have a list of Listitems.

A <- closed B <- closed C <- closed

viewHeights empty

expand one (B)

A <- closed B <- expanded C <- closed

viewHeights (pos: 1, height: 100)

and click a button. the button collapses all items with animateCollapse() and removes a item from the database

A <- closed B <- closed C <- closed

Here is my change. Clear view heights.

Widhtout the Change: viewHeights (pos: 1, height: 100)

notifyDataSetChanged() is called and the ListView items get recreated.

B is deleted (no view)

A <- closed C <- expanded

Here is the error: C is expanded because viewHeights still hold that pos 1 has the height 100. Thats why i drop viewheights.