Skip to content

Commit

Permalink
Updated Visibility and Animation Duration functioanlity
Browse files Browse the repository at this point in the history
  • Loading branch information
Jesse Farebrother committed Mar 31, 2013
1 parent b489d15 commit d3473b9
Showing 1 changed file with 27 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit d3473b9

Please sign in to comment.