Search in sources :

Example 1 with HeightAnimation

use of com.ramotion.foldingcell.animations.HeightAnimation in project folding-cell-android by Ramotion.

the class FoldingCell method startExpandHeightAnimation.

/**
     * Prepare and start height expand animation for FoldingCellLayout
     *
     * @param partAnimationDuration one part animate duration
     * @param viewHeights           heights of animation parts
     */
protected void startExpandHeightAnimation(ArrayList<Integer> viewHeights, int partAnimationDuration) {
    if (viewHeights == null || viewHeights.isEmpty())
        throw new IllegalArgumentException("ViewHeights array must have at least 2 elements");
    ArrayList<Animation> heightAnimations = new ArrayList<>();
    int fromHeight = viewHeights.get(0);
    int delay = 0;
    int animationDuration = partAnimationDuration - delay;
    for (int i = 1; i < viewHeights.size(); i++) {
        int toHeight = fromHeight + viewHeights.get(i);
        HeightAnimation heightAnimation = new HeightAnimation(this, fromHeight, toHeight, animationDuration).withInterpolator(new DecelerateInterpolator());
        heightAnimation.setStartOffset(delay);
        heightAnimations.add(heightAnimation);
        fromHeight = toHeight;
    }
    createAnimationChain(heightAnimations, this);
    this.startAnimation(heightAnimations.get(0));
}
Also used : DecelerateInterpolator(android.view.animation.DecelerateInterpolator) HeightAnimation(com.ramotion.foldingcell.animations.HeightAnimation) ArrayList(java.util.ArrayList) HeightAnimation(com.ramotion.foldingcell.animations.HeightAnimation) Animation(android.view.animation.Animation) FoldAnimation(com.ramotion.foldingcell.animations.FoldAnimation)

Aggregations

Animation (android.view.animation.Animation)1 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)1 FoldAnimation (com.ramotion.foldingcell.animations.FoldAnimation)1 HeightAnimation (com.ramotion.foldingcell.animations.HeightAnimation)1 ArrayList (java.util.ArrayList)1