use of com.ramotion.foldingcell.animations.FoldAnimation in project folding-cell-android by Ramotion.
the class FoldingCell method startFoldAnimation.
/**
* Start fold animation
*
* @param foldingCellElements ordered list with animation parts from top to bottom
* @param foldingLayout prepared layout for animation parts
* @param part90degreeAnimationDuration animation duration for 90 degree rotation
* @param animationEndListener animation end callback
*/
protected void startFoldAnimation(ArrayList<FoldingCellView> foldingCellElements, ViewGroup foldingLayout, int part90degreeAnimationDuration, AnimationEndListener animationEndListener) {
for (FoldingCellView foldingCellElement : foldingCellElements) foldingLayout.addView(foldingCellElement);
Collections.reverse(foldingCellElements);
int nextDelay = 0;
for (int i = 0; i < foldingCellElements.size(); i++) {
FoldingCellView cell = foldingCellElements.get(i);
cell.setVisibility(VISIBLE);
// not FIRST(BOTTOM) element - animate front view
if (i != 0) {
FoldAnimation foldAnimation = new FoldAnimation(FoldAnimation.FoldAnimationMode.UNFOLD_UP, mCameraHeight, part90degreeAnimationDuration).withStartOffset(nextDelay).withInterpolator(new DecelerateInterpolator());
// if last(top) element - add end listener
if (i == foldingCellElements.size() - 1) {
foldAnimation.setAnimationListener(animationEndListener);
}
cell.animateFrontView(foldAnimation);
nextDelay = nextDelay + part90degreeAnimationDuration;
}
// if not last(top) element - animate whole view
if (i != foldingCellElements.size() - 1) {
cell.startAnimation(new FoldAnimation(FoldAnimation.FoldAnimationMode.FOLD_UP, mCameraHeight, part90degreeAnimationDuration).withStartOffset(nextDelay).withInterpolator(new DecelerateInterpolator()));
nextDelay = nextDelay + part90degreeAnimationDuration;
}
}
}
use of com.ramotion.foldingcell.animations.FoldAnimation in project folding-cell-android by Ramotion.
the class FoldingCell method startUnfoldAnimation.
/**
* Start unfold animation
*
* @param foldingCellElements ordered list with animation parts from top to bottom
* @param foldingLayout prepared layout for animation parts
* @param part90degreeAnimationDuration animation duration for 90 degree rotation
* @param animationEndListener animation end callback
*/
protected void startUnfoldAnimation(ArrayList<FoldingCellView> foldingCellElements, ViewGroup foldingLayout, int part90degreeAnimationDuration, AnimationEndListener animationEndListener) {
int nextDelay = 0;
for (int i = 0; i < foldingCellElements.size(); i++) {
FoldingCellView cell = foldingCellElements.get(i);
cell.setVisibility(VISIBLE);
foldingLayout.addView(cell);
// if not first(top) element - animate whole view
if (i != 0) {
FoldAnimation foldAnimation = new FoldAnimation(FoldAnimation.FoldAnimationMode.UNFOLD_DOWN, mCameraHeight, part90degreeAnimationDuration).withStartOffset(nextDelay).withInterpolator(new DecelerateInterpolator());
// if last(bottom) element - add end listener
if (i == foldingCellElements.size() - 1) {
foldAnimation.setAnimationListener(animationEndListener);
}
nextDelay = nextDelay + part90degreeAnimationDuration;
cell.startAnimation(foldAnimation);
}
// not last(bottom) element - animate front view
if (i != foldingCellElements.size() - 1) {
cell.animateFrontView(new FoldAnimation(FoldAnimation.FoldAnimationMode.FOLD_DOWN, mCameraHeight, part90degreeAnimationDuration).withStartOffset(nextDelay).withInterpolator(new DecelerateInterpolator()));
nextDelay = nextDelay + part90degreeAnimationDuration;
}
}
}
Aggregations