Search in sources :

Example 11 with AnimatorSet

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();
}
Also used : AnimatorSet(com.nineoldandroids.animation.AnimatorSet)

Example 12 with AnimatorSet

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;
}
Also used : ValueAnimator(com.nineoldandroids.animation.ValueAnimator) Animator(com.nineoldandroids.animation.Animator) ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) AnimatorSet(com.nineoldandroids.animation.AnimatorSet)

Example 13 with AnimatorSet

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();
}
Also used : ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) Animator(com.nineoldandroids.animation.Animator) ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) ArrayList(java.util.ArrayList) AnimatorSet(com.nineoldandroids.animation.AnimatorSet) View(android.view.View)

Example 14 with AnimatorSet

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);
}
Also used : ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) Animator(com.nineoldandroids.animation.Animator) AnimatorSet(com.nineoldandroids.animation.AnimatorSet)

Example 15 with AnimatorSet

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;
}
Also used : ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) Animator(com.nineoldandroids.animation.Animator) ArrayList(java.util.ArrayList) AnimatorSet(com.nineoldandroids.animation.AnimatorSet)

Aggregations

AnimatorSet (com.nineoldandroids.animation.AnimatorSet)57 ObjectAnimator (com.nineoldandroids.animation.ObjectAnimator)42 Animator (com.nineoldandroids.animation.Animator)24 AnimatorListenerAdapter (com.nineoldandroids.animation.AnimatorListenerAdapter)11 View (android.view.View)6 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)4 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)4 SuppressLint (android.annotation.SuppressLint)3 Paint (android.graphics.Paint)3 OvershootInterpolator (android.view.animation.OvershootInterpolator)3 Point (android.graphics.Point)2 DisplayMetrics (android.util.DisplayMetrics)2 LinearInterpolator (android.view.animation.LinearInterpolator)2 AdapterView (android.widget.AdapterView)2 ImageView (android.widget.ImageView)2 TextView (android.widget.TextView)2 ValueAnimator (com.nineoldandroids.animation.ValueAnimator)2 IDetailView (com.yydcdut.note.views.note.IDetailView)2 FontTextView (com.yydcdut.note.widget.FontTextView)2 RevealView (com.yydcdut.note.widget.RevealView)2