Skip to content

Commit

Permalink
Animate expansion of last group in list
Browse files Browse the repository at this point in the history
This is a temp. fix for this issue. This will only work in API levels 14 (ICS) and up.
  • Loading branch information
idunnololz committed Sep 23, 2014
1 parent 3ad93a3 commit eae7132
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt

# Project target.
target=android-19
target=android-20
11 changes: 10 additions & 1 deletion src/com/idunnololz/widgets/AnimatedExpandableListView.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
import java.util.ArrayList;
import java.util.List;

import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.util.AttributeSet;
import android.util.SparseArray;
import android.view.View;
Expand Down Expand Up @@ -90,7 +92,8 @@ public class AnimatedExpandableListView extends ExpandableListView {
* the collapsed group.
*/

private static final String TAG = AnimatedExpandableListAdapter.class.getSimpleName();
@SuppressWarnings("unused")
private static final String TAG = AnimatedExpandableListAdapter.class.getSimpleName();

/**
* The duration of the expand/collapse animations
Expand Down Expand Up @@ -132,7 +135,13 @@ public void setAdapter(ExpandableListAdapter adapter) {
* @return Returns true if the group was expanded. False if the group was
* already expanded.
*/
@SuppressLint("NewApi")
public boolean expandGroupWithAnimation(int groupPos) {
boolean lastGroup = groupPos == adapter.getGroupCount() - 1;
if (lastGroup && Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
return expandGroup(groupPos, true);
}

int groupFlatPos = getFlatListPosition(getPackedPositionForGroup(groupPos));
if (groupFlatPos != -1) {
int childIndex = groupFlatPos - getFirstVisiblePosition();
Expand Down

1 comment on commit eae7132

@Sottti
Copy link

@Sottti Sottti commented on eae7132 Oct 27, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi there,

thanks for sharing.

The expand animation for the last group is not working for me.

Nexus 5, Android 4.4.4.

All the other ones are fine but the last is not working.

Please sign in to comment.