From d3473b921e04b1db7ba1314cb5080b3de5b8efea Mon Sep 17 00:00:00 2001 From: Jesse Farebrother Date: Sun, 31 Mar 2013 13:54:20 -0600 Subject: [PATCH] Updated Visibility and Animation Duration functioanlity --- .../AbstractSlideExpandableListAdapter.java | 30 +++++++++++++++++-- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/library/src/com/tjerkw/slideexpandable/library/AbstractSlideExpandableListAdapter.java b/library/src/com/tjerkw/slideexpandable/library/AbstractSlideExpandableListAdapter.java index e875f23..e98a4ae 100644 --- a/library/src/com/tjerkw/slideexpandable/library/AbstractSlideExpandableListAdapter.java +++ b/library/src/com/tjerkw/slideexpandable/library/AbstractSlideExpandableListAdapter.java @@ -32,6 +32,13 @@ public abstract class AbstractSlideExpandableListAdapter extends WrapperListAdap * Otherwise it points to the position of the last expanded list item */ private int lastOpenPosition = -1; + + /** + * Default Animation duration + * Set animation duration with @see setAnimationDuration + */ + private int animationDuration = 330; + /** * A list of positions of all list items that are expanded. * Normally only one is expanded. But a mode to expand @@ -101,8 +108,25 @@ public View getView(int position, View view, ViewGroup viewGroup) { * * @return the duration of the anim in ms */ - protected int getAnimationDuration() { - return 330; + public int getAnimationDuration() { + return animationDuration; + } + /** + * Set's the Animation duration for the Expandable animation + * + * @param duration The duration as an integer in MS (duration > 0) + */ + public void setAnimationDuration(int duration) { + if(duration > 0) animationDuration = duration; + } + /** + * Check's if any position is currently Expanded + * To collapse the open item @see collapseLastOpen + * + * @return boolean True if there is currently an item expanded, otherwise false + */ + public boolean isAnyItemExpanded() { + return (lastOpenPosition != -1) ? true : false; } public void enableFor(View parent, int position) { @@ -223,7 +247,7 @@ private void animateView(final View target, final int type) { * @return true if an item was closed, false otherwise */ public boolean collapseLastOpen() { - if(lastOpenPosition != -1) { + if(isAnyItemExpanded()) { // if visible animate it out if(lastOpen != null) { animateView(lastOpen, ExpandCollapseAnimation.COLLAPSE);