Search in sources :

Example 31 with ObjectAnimator

use of com.nineoldandroids.animation.ObjectAnimator in project Rashr by DsLNeXuS.

the class CardStack method getClickListener.

private OnClickListener getClickListener(final CardStack cardStack, final RelativeLayout container, final int index) {
    return new OnClickListener() {

        @Override
        public void onClick(View v) {
            // init views array
            View[] views = new View[container.getChildCount()];
            for (int i = 0; i < views.length; i++) {
                views[i] = container.getChildAt(i);
            }
            int last = views.length - 1;
            if (index != last) {
                if (index == 0) {
                    onClickFirstCard(cardStack, container, index, views);
                } else if (index < last) {
                    onClickOtherCard(cardStack, container, index, views, last);
                }
            }
        }

        public void onClickFirstCard(final CardStack cardStack, final RelativeLayout frameLayout, final int index, View[] views) {
            // run through all the cards
            for (int i = 0; i < views.length; i++) {
                ObjectAnimator anim = null;
                if (i == 0) {
                    // the first goes all the way down
                    float downFactor = 0;
                    if (views.length > 2) {
                        downFactor = convertDpToPixel((_45F) * (views.length - 1) - 1);
                    } else {
                        downFactor = convertDpToPixel(_45F);
                    }
                    anim = ObjectAnimator.ofFloat(views[i], NINE_OLD_TRANSLATION_Y, 0, downFactor);
                    anim.addListener(getAnimationListener(cardStack, frameLayout, index, views[index]));
                } else if (i == 1) {
                    // the second goes up just a bit
                    float upFactor = convertDpToPixel(-17f);
                    anim = ObjectAnimator.ofFloat(views[i], NINE_OLD_TRANSLATION_Y, 0, upFactor);
                } else {
                    // the rest go up by one card
                    float upFactor = convertDpToPixel(-1 * _45F);
                    anim = ObjectAnimator.ofFloat(views[i], NINE_OLD_TRANSLATION_Y, 0, upFactor);
                }
                if (anim != null)
                    anim.start();
            }
        }

        public void onClickOtherCard(final CardStack cardStack, final RelativeLayout frameLayout, final int index, View[] views, int last) {
            // if clicked card is in middle
            for (int i = index; i <= last; i++) {
                // run through the cards from the clicked position
                // and on until the end
                ObjectAnimator anim = null;
                if (i == index) {
                    // the selected card goes all the way down
                    float downFactor = convertDpToPixel(_45F * (last - i) + _12F);
                    anim = ObjectAnimator.ofFloat(views[i], NINE_OLD_TRANSLATION_Y, 0, downFactor);
                    anim.addListener(getAnimationListener(cardStack, frameLayout, index, views[index]));
                } else {
                    // the rest go up by one
                    float upFactor = convertDpToPixel(_45F * -1);
                    anim = ObjectAnimator.ofFloat(views[i], NINE_OLD_TRANSLATION_Y, 0, upFactor);
                }
                if (anim != null)
                    anim.start();
            }
        }
    };
}
Also used : ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) RelativeLayout(android.widget.RelativeLayout) OnClickListener(android.view.View.OnClickListener) TextView(android.widget.TextView) View(android.view.View)

Example 32 with ObjectAnimator

use of com.nineoldandroids.animation.ObjectAnimator in project AndroidSweetSheet by zzz40500.

the class MenuRVAdapter method animation.

private void animation(MenuVH menuVH) {
    ViewHelper.setAlpha(menuVH.itemView, 0);
    ViewHelper.setTranslationY(menuVH.itemView, 300);
    ObjectAnimator translationY = ObjectAnimator.ofFloat(menuVH.itemView, "translationY", 500, 0);
    translationY.setDuration(300);
    translationY.setInterpolator(new OvershootInterpolator(1.6f));
    ObjectAnimator alphaIn = ObjectAnimator.ofFloat(menuVH.itemView, "alpha", 0, 1);
    alphaIn.setDuration(100);
    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.playTogether(translationY, alphaIn);
    animatorSet.setStartDelay(30 * menuVH.getAdapterPosition());
    animatorSet.start();
}
Also used : OvershootInterpolator(android.view.animation.OvershootInterpolator) ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) AnimatorSet(com.nineoldandroids.animation.AnimatorSet)

Example 33 with ObjectAnimator

use of com.nineoldandroids.animation.ObjectAnimator in project AndroidSweetSheet by zzz40500.

the class Delegate method dismissShowdown.

/**
     * 隐藏模糊背景
     */
protected void dismissShowdown() {
    ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(mBg, "alpha", 1, 0);
    objectAnimator.setDuration(400);
    objectAnimator.start();
    objectAnimator.addListener(new SimpleAnimationListener() {

        @Override
        public void onAnimationEnd(Animator animation) {
            mParentVG.removeView(mBg);
        }
    });
}
Also used : ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) Animator(com.nineoldandroids.animation.Animator) ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) SimpleAnimationListener(com.mingle.SimpleAnimationListener)

Example 34 with ObjectAnimator

use of com.nineoldandroids.animation.ObjectAnimator in project AndroidSweetSheet by zzz40500.

the class IndicatorView method alphaShow.

public void alphaShow(boolean isAnimation) {
    if (isAnimation) {
        ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(this, "alpha", 0, 1);
        objectAnimator.setDuration(300);
        objectAnimator.start();
    } else {
        ViewHelper.setAlpha(this, 1);
    }
}
Also used : ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator)

Example 35 with ObjectAnimator

use of com.nineoldandroids.animation.ObjectAnimator in project MaterialCalendar by Haoxiqiang.

the class MemoFragment method release.

void release() {
    ObjectAnimator objectAnimator = ObjectAnimator.ofInt(mBluePair, "bottom", mBluePair.getBottom(), startBluePairBottom);
    objectAnimator.addListener(new SimpleListener() {

        @Override
        public void onAnimationEnd(Animator animator) {
            disappearBluePair();
        }
    });
    objectAnimator.setInterpolator(ACCELERATE_DECELERATE);
    objectAnimator.start();
}
Also used : ArcAnimator(io.codetail.animation.arcanimator.ArcAnimator) Animator(com.nineoldandroids.animation.Animator) SupportAnimator(io.codetail.animation.SupportAnimator) ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator)

Aggregations

ObjectAnimator (com.nineoldandroids.animation.ObjectAnimator)81 AnimatorSet (com.nineoldandroids.animation.AnimatorSet)27 Animator (com.nineoldandroids.animation.Animator)20 View (android.view.View)11 PropertyValuesHolder (com.nineoldandroids.animation.PropertyValuesHolder)10 Keyframe (com.nineoldandroids.animation.Keyframe)9 Paint (android.graphics.Paint)8 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)8 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)6 TextView (android.widget.TextView)5 AdapterView (android.widget.AdapterView)4 AnimatorListenerAdapter (com.nineoldandroids.animation.AnimatorListenerAdapter)4 SuppressLint (android.annotation.SuppressLint)3 TargetApi (android.annotation.TargetApi)3 LinearInterpolator (android.view.animation.LinearInterpolator)3 OvershootInterpolator (android.view.animation.OvershootInterpolator)3 AbsListView (android.widget.AbsListView)3 ListView (android.widget.ListView)3 ValueAnimator (com.nineoldandroids.animation.ValueAnimator)3 SupportAnimator (io.codetail.animation.SupportAnimator)3