use of com.nineoldandroids.animation.AnimatorSet in project AndroidResideMenu by SpecialCyCi.
the class ResideMenu method openMenu.
/**
* Show the menu;
*/
public void openMenu(int direction) {
setScaleDirection(direction);
isOpened = true;
AnimatorSet scaleDown_activity = buildScaleDownAnimation(viewActivity, mScaleValue, mScaleValue);
AnimatorSet scaleDown_shadow = buildScaleDownAnimation(imageViewShadow, mScaleValue + shadowAdjustScaleX, mScaleValue + shadowAdjustScaleY);
AnimatorSet alpha_menu = buildMenuAnimation(scrollViewMenu, 1.0f);
scaleDown_shadow.addListener(animationListener);
scaleDown_activity.playTogether(scaleDown_shadow);
scaleDown_activity.playTogether(alpha_menu);
scaleDown_activity.start();
}
use of com.nineoldandroids.animation.AnimatorSet in project ElasticDownload by Tibolte.
the class PathAnimatorInflater method createAnimatorFromXml.
private static Animator createAnimatorFromXml(Context c, Resources res, Resources.Theme theme, XmlPullParser parser, AttributeSet attrs, AnimatorSet parent, int sequenceOrdering, float pixelSize) throws XmlPullParserException, IOException {
Animator anim = null;
ArrayList<Animator> childAnims = null;
// Make sure we are on a start tag.
int type;
int depth = parser.getDepth();
while (((type = parser.next()) != XmlPullParser.END_TAG || parser.getDepth() > depth) && type != XmlPullParser.END_DOCUMENT) {
if (type != XmlPullParser.START_TAG) {
continue;
}
String name = parser.getName();
if (name.equals("objectAnimator")) {
anim = loadObjectAnimator(c, res, theme, attrs, pixelSize);
} else if (name.equals("animator")) {
anim = loadAnimator(c, res, theme, attrs, null, pixelSize);
} else if (name.equals("set")) {
anim = new AnimatorSet();
//TODO: don't care about 'set' attributes for now
// TypedArray a;
// if (theme != null) {
// a = theme.obtainStyledAttributes(attrs, AnimatorSet, 0, 0);
// } else {
// a = res.obtainAttributes(attrs, AnimatorSet);
// }
// int ordering = a.getInt(R.styleable.AnimatorSet_ordering,
// TOGETHER);
createAnimatorFromXml(c, res, theme, parser, attrs, (AnimatorSet) anim, TOGETHER, pixelSize);
// a.recycle();
} else {
throw new RuntimeException("Unknown animator name: " + parser.getName());
}
if (parent != null) {
if (childAnims == null) {
childAnims = new ArrayList<Animator>();
}
childAnims.add(anim);
}
}
if (parent != null && childAnims != null) {
Animator[] animsArray = new Animator[childAnims.size()];
int index = 0;
for (Animator a : childAnims) {
animsArray[index++] = a;
}
if (sequenceOrdering == TOGETHER) {
parent.playTogether(animsArray);
} else {
parent.playSequentially(animsArray);
}
}
return anim;
}
use of com.nineoldandroids.animation.AnimatorSet in project Context-Menu.Android by Yalantis.
the class MenuAdapter method buildChosenAnimation.
/**
* Builds and runs chosen item and menu closing animation
*/
private void buildChosenAnimation(int childIndex) {
List<Animator> fadeOutTextTopAnimatorList = new ArrayList<>();
List<Animator> closeToBottomImageAnimatorList = new ArrayList<>();
for (int i = 0; i < childIndex; i++) {
View view = mMenuWrapper.getChildAt(i);
resetVerticalAnimation(view, true);
closeToBottomImageAnimatorList.add(AnimatorUtils.rotationCloseVertical(view));
fadeOutTextTopAnimatorList.add(AnimatorUtils.fadeOutSet(mTextWrapper.getChildAt(i), mContext.getResources().getDimension(R.dimen.text_right_translation)));
}
AnimatorSet closeToBottom = new AnimatorSet();
closeToBottom.playSequentially(closeToBottomImageAnimatorList);
AnimatorSet fadeOutTop = new AnimatorSet();
fadeOutTop.playSequentially(fadeOutTextTopAnimatorList);
List<Animator> fadeOutTextBottomAnimatorList = new ArrayList<>();
List<Animator> closeToTopAnimatorObjects = new ArrayList<>();
for (int i = getItemCount() - 1; i > childIndex; i--) {
View view = mMenuWrapper.getChildAt(i);
resetVerticalAnimation(view, false);
closeToTopAnimatorObjects.add(AnimatorUtils.rotationCloseVertical(view));
fadeOutTextBottomAnimatorList.add(AnimatorUtils.fadeOutSet(mTextWrapper.getChildAt(i), mContext.getResources().getDimension(R.dimen.text_right_translation)));
}
AnimatorSet closeToTop = new AnimatorSet();
closeToTop.playSequentially(closeToTopAnimatorObjects);
AnimatorSet fadeOutBottom = new AnimatorSet();
fadeOutBottom.playSequentially(fadeOutTextBottomAnimatorList);
resetSideAnimation(mMenuWrapper.getChildAt(childIndex));
ObjectAnimator closeToRight = AnimatorUtils.rotationCloseToRight(mMenuWrapper.getChildAt(childIndex));
closeToRight.addListener(mChosenItemFinishAnimatorListener);
AnimatorSet fadeOutChosenText = AnimatorUtils.fadeOutSet(mTextWrapper.getChildAt(childIndex), mContext.getResources().getDimension(R.dimen.text_right_translation));
AnimatorSet imageFullAnimatorSet = new AnimatorSet();
imageFullAnimatorSet.play(closeToBottom).with(closeToTop);
AnimatorSet textFullAnimatorSet = new AnimatorSet();
textFullAnimatorSet.play(fadeOutTop).with(fadeOutBottom);
if (closeToBottomImageAnimatorList.size() >= closeToTopAnimatorObjects.size()) {
imageFullAnimatorSet.play(closeToBottom).before(closeToRight);
textFullAnimatorSet.play(fadeOutTop).before(fadeOutChosenText);
} else {
imageFullAnimatorSet.play(closeToTop).before(closeToRight);
textFullAnimatorSet.play(fadeOutBottom).before(fadeOutChosenText);
}
AnimatorSet fullAnimatorSet = new AnimatorSet();
fullAnimatorSet.playTogether(imageFullAnimatorSet, textFullAnimatorSet);
fullAnimatorSet.setDuration(mAnimationDurationMilis);
fullAnimatorSet.setInterpolator(new HesitateInterpolator());
fullAnimatorSet.start();
}
use of com.nineoldandroids.animation.AnimatorSet in project Context-Menu.Android by Yalantis.
the class MenuAdapter method fillOpenClosingAnimations.
/**
* Filling arrays of animations to build Set of Closing / Opening animations
*/
private void fillOpenClosingAnimations(boolean isCloseAnimation, List<Animator> textAnimations, List<Animator> imageAnimations, int wrapperPosition) {
AnimatorSet textAnimatorSet = new AnimatorSet();
Animator textAppearance = isCloseAnimation ? AnimatorUtils.alfaDisappear(mTextWrapper.getChildAt(wrapperPosition)) : AnimatorUtils.alfaAppear(mTextWrapper.getChildAt(wrapperPosition));
Animator textTranslation = isCloseAnimation ? AnimatorUtils.translationRight(mTextWrapper.getChildAt(wrapperPosition), mContext.getResources().getDimension(R.dimen.text_right_translation)) : AnimatorUtils.translationLeft(mTextWrapper.getChildAt(wrapperPosition), mContext.getResources().getDimension(R.dimen.text_right_translation));
textAnimatorSet.playTogether(textAppearance, textTranslation);
textAnimations.add(textAnimatorSet);
Animator imageRotation = isCloseAnimation ? wrapperPosition == 0 ? AnimatorUtils.rotationCloseToRight(mMenuWrapper.getChildAt(wrapperPosition)) : AnimatorUtils.rotationCloseVertical(mMenuWrapper.getChildAt(wrapperPosition)) : wrapperPosition == 0 ? AnimatorUtils.rotationOpenFromRight(mMenuWrapper.getChildAt(wrapperPosition)) : AnimatorUtils.rotationOpenVertical(mMenuWrapper.getChildAt(wrapperPosition));
imageAnimations.add(imageRotation);
}
use of com.nineoldandroids.animation.AnimatorSet in project Context-Menu.Android by Yalantis.
the class MenuAdapter method setOpenCloseAnimation.
/**
* Creates Open / Close AnimatorSet
*/
private AnimatorSet setOpenCloseAnimation(boolean isCloseAnimation) {
List<Animator> textAnimations = new ArrayList<>();
List<Animator> imageAnimations = new ArrayList<>();
if (isCloseAnimation) {
for (int i = getItemCount() - 1; i >= 0; i--) {
fillOpenClosingAnimations(true, textAnimations, imageAnimations, i);
}
} else {
for (int i = 0; i < getItemCount(); i++) {
fillOpenClosingAnimations(false, textAnimations, imageAnimations, i);
}
}
AnimatorSet textCloseAnimatorSet = new AnimatorSet();
textCloseAnimatorSet.playSequentially(textAnimations);
AnimatorSet imageCloseAnimatorSet = new AnimatorSet();
imageCloseAnimatorSet.playSequentially(imageAnimations);
AnimatorSet animatorFullSet = new AnimatorSet();
animatorFullSet.playTogether(imageCloseAnimatorSet, textCloseAnimatorSet);
animatorFullSet.setDuration(mAnimationDurationMilis);
animatorFullSet.addListener(mCloseOpenAnimatorListener);
animatorFullSet.setStartDelay(0);
animatorFullSet.setInterpolator(new HesitateInterpolator());
return animatorFullSet;
}
Aggregations