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

Update the ExpandCollapseAnimation file #6

Closed grivos closed 11 years ago

grivos commented 11 years ago

I had troubles with animations on target views with layout height set to wrap_content, these changes helped me out.

tjerkw commented 11 years ago

Actually I struggled with this same issue, but for me, getHeight doesnt work properly. The expand animation does not show up anymore. Only the collapse animation works.

The reason this is because when the expandable view is collapsed, its view is reported as 0, so getHeight() will return 0, and thus the animation will animate from 0 to 0, when the animation finishes to item is set to visible.

I added some logging code just after the getHeight in your solution on the /sample project:

Log.d("ExpandCollapseAnimation", "getHeight = " + mEndHeight + " , layoutParams.height = " + mAnimatedView.getLayoutParams().height);

When an item A is expanded, and you try to expand a differnt item B, then there are two animations. Expand animation on item B Collapse animation on item A

For the item B to show (animation fails to work with getHeight):

01-12 01:59:46.718: DEBUG/ExpandCollapseAnimation(15147): getHeight = 0 , layoutParams.height = 150

And for the item A to hide (works properly):

01-12 01:59:46.726: DEBUG/ExpandCollapseAnimation(15147): getHeight = 150 , layoutParams.height = 150

Could you try to get your solution to work with the /sample project. If it works i'm glad to accept it.

tjerkw commented 11 years ago

Thanks for your input, i think I solved it. Please follow issue #2 for more info on the solution.

grivos commented 11 years ago

Hey, take a look at my last commit a1fac98, tell me what do you think. Thanks!

tjerkw commented 11 years ago

@grivos I like this commit: https://github.com/grivos/Android-SlideExpandableListView/commit/b89c66b83560987968c5641d58d3955c0e9d00e2 It usese the nice SpareIntArray as i should have done in the first place Could you generate a pull request?

I dont like https://github.com/tjerkw/Android-SlideExpandableListView/commit/a1fac98. In Android event listeners are always interfaces. You shoudnt have to extend an Adapter in order to listen for events.

Actually i think my new ActionSlideExpandableListView which was commited before your changes actually solve your problem.

https://github.com/grivos/Android-SlideExpandableListView/blob/de3b710028986d5de103c043a3184259f6d9dff4/library/src/com/tjerkw/slideexpandable/library/ActionSlideExpandableListView.java

See how it is used here:

https://github.com/tjerkw/Android-SlideExpandableListView/blob/master/sample/src/com/tjerkw/slideexpandable/sample/ExampleActivity.java

tjerkw commented 11 years ago

Ok i'm cherry picking only that change.

Ok done: https://github.com/tjerkw/Android-SlideExpandableListView/commit/99156dc9f629161a806ec6c6eefc73c03ca492d6

You are now an official contributor :+1:

grivos commented 11 years ago

Cool! This library can really make an app look much more polished. And I saw your example of listeners to expandable views - you're right, it is a better design.

tjerkw commented 11 years ago

Ok i'm closing this issue since it is fixed.

tjerkw commented 11 years ago

@grivos i added you as a contributor to this project. This means you got full write access to the repo.

I'm doing this because in the end i think this is good for this project. You don't have to commit anything, but if you want to, you're free todo so. :-)

jelgh commented 11 years ago

Thanks :)