Skip to content

Commit

Permalink
Merge pull request #17 from AAkira/v1.3.0
Browse files Browse the repository at this point in the history
V1.3.0
  • Loading branch information
AAkira committed Oct 5, 2015
2 parents 56ac176 + 024b13a commit b4491de
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 24 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ buildscript {
}
dependencies {
compile 'com.github.aakira:expandable-layout:1.2.0@aar'
compile 'com.github.aakira:expandable-layout:1.3.0@aar'
}
```

Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ COMPILE_SDK_VERSION=23
BUILD_TOOLS_VERSION=22.0.1
MIN_SDK_VERSION=11
TARGET_SDK_VERSION=23
VERSION_CODE=3
VERSION_NAME=1.2.0
VERSION_CODE=4
VERSION_NAME=1.3.0

SUPPORT_APP_COMPAT_VERSION=23.0.1

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,27 @@ public interface ExpandableLayout {
}

/**
* Starts animation the state of the view to the inverse of its current state
* Starts animation the state of the view to the inverse of its current state.
*/
void toggle();

/**
* Starts expand animation
* Starts expand animation.
*/
void expand();

/**
* Starts collapse animation
* Starts collapse animation.
*/
void collapse();

/**
* Sets the expandable layout listener
* Initializes this layout.
*/
void initLayout();

/**
* Sets the expandable layout listener.
*
* @param listener ExpandableLayoutListener
*/
Expand All @@ -65,12 +70,19 @@ public interface ExpandableLayout {
void setDuration(final int duration);

/**
* Sets state of expanse
* Sets state of expanse.
*
* @param expanded The layout is visible if expanded is true
*/
void setExpanded(final boolean expanded);

/**
* Gets state of expanse.
*
* @return true if the layout is visible
*/
boolean isExpanded();

/**
* The time interpolator used in calculating the elapsed fraction of this animation. The
* interpolator determines whether the animation runs with linear or non-linear motion,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,6 @@ protected void onRestoreInstanceState(final Parcelable state) {
savedState = ss;
}

@Override
public void requestLayout() {
isArranged = false;
super.requestLayout();
}

/**
* {@inheritDoc}
*/
Expand Down Expand Up @@ -188,6 +182,20 @@ public void collapse() {
createExpandAnimator(getCurrentPosition(), closePosition).start();
}

/**
* {@inheritDoc}
*/
@Override
public void initLayout() {
closePosition = 0;
layoutSize = 0;
isArranged = false;
isCalculatedSize = false;
savedState = null;

super.requestLayout();
}

/**
* {@inheritDoc}
*/
Expand All @@ -209,6 +217,14 @@ public void setExpanded(boolean expanded) {
requestLayout();
}

/**
* {@inheritDoc}
*/
@Override
public boolean isExpanded() {
return isExpanded;
}

/**
* {@inheritDoc}
*/
Expand Down Expand Up @@ -353,7 +369,6 @@ public void onAnimationUpdate(final ValueAnimator animator) {
@Override
public void onAnimationStart(Animator animator) {
isAnimating = true;

if (listener == null) {
return;
}
Expand All @@ -371,13 +386,15 @@ public void onAnimationStart(Animator animator) {
@Override
public void onAnimationEnd(Animator animator) {
isAnimating = false;
final int currentSize = isVertical()
? getLayoutParams().height : getLayoutParams().width;
isExpanded = currentSize > closePosition;

if (listener == null) {
return;
}
listener.onAnimationEnd();

final int currentSize = isVertical()
? getLayoutParams().height : getLayoutParams().width;
if (currentSize == layoutSize) {
listener.onOpened();
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,6 @@ protected void onRestoreInstanceState(final Parcelable state) {
savedState = ss;
}

@Override
public void requestLayout() {
isArranged = false;
super.requestLayout();
}

/**
* {@inheritDoc}
*/
Expand Down Expand Up @@ -177,6 +171,19 @@ public void collapse() {
createExpandAnimator(layoutWeight, 0).start();
}

/**
* {@inheritDoc}
*/
@Override
public void initLayout() {
layoutWeight = 0;
isArranged = false;
isCalculatedSize = false;
savedState = null;

super.requestLayout();
}

/**
* {@inheritDoc}
*/
Expand All @@ -198,6 +205,14 @@ public void setExpanded(boolean expanded) {
requestLayout();
}

/**
* {@inheritDoc}
*/
@Override
public boolean isExpanded() {
return isExpanded;
}

/**
* {@inheritDoc}
*/
Expand Down Expand Up @@ -256,6 +271,8 @@ public void onAnimationStart(Animator animation) {
@Override
public void onAnimationEnd(Animator animation) {
isAnimating = false;
final float currentWeight = ((LinearLayout.LayoutParams) getLayoutParams()).weight;
isExpanded = currentWeight > 0;

if (listener == null) {
return;
Expand All @@ -266,7 +283,6 @@ public void onAnimationEnd(Animator animation) {
return;
}

final float currentWeight = ((LinearLayout.LayoutParams) getLayoutParams()).weight;
if (currentWeight == layoutWeight) {
listener.onOpened();
return;
Expand Down

0 comments on commit b4491de

Please sign in to comment.