Java Code Examples for com.nineoldandroids.animation.ObjectAnimator#setRepeatCount()

The following examples show how to use com.nineoldandroids.animation.ObjectAnimator#setRepeatCount() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AnimationUtil.java    From sms-ticket with Apache License 2.0 5 votes vote down vote up
public static void setFlipAnimation(final ImageView view, final ObjectAnimator animator, final int firstImage,
                                    final int secondImage, final Context c) {
    if (secondImage == NO_ANIMATION) {
        view.setImageResource(firstImage);
        animator.end();
        ViewCompat.setHasTransientState(view, false);
    } else {
        animator.setRepeatCount(ObjectAnimator.INFINITE);
        animator.setDuration(1300);
        animator.setInterpolator(new LinearInterpolator());
        animator.setRepeatMode(ValueAnimator.RESTART);

        animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            final Drawable shape1 = c.getResources().getDrawable(firstImage);
            final Drawable shape2 = c.getResources().getDrawable(secondImage);
            Drawable currentDrawable = null;

            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                float angle = (Float)animation.getAnimatedValue();
                int quadrant = (int)(angle / 90) + 1;
                if ((quadrant == 1 || quadrant == 4) && shape1 != currentDrawable) {
                    view.setImageDrawable(shape1);
                    currentDrawable = shape1;
                } else if ((quadrant == 2 || quadrant == 3) && currentDrawable != shape2) {
                    view.setImageDrawable(shape2);
                    currentDrawable = shape2;
                }
            }
        });
        animator.start();
        ViewCompat.setHasTransientState(view, true);
    }
}
 
Example 2
Source File: AnimUtil.java    From PullRefreshView with Apache License 2.0 5 votes vote down vote up
public static Animator startRotation(View view, float toRotation, long duration, long startDelay, int times) {
    ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(view, "rotation", ViewHelper.getRotation(view), toRotation).setDuration(duration);
    objectAnimator.setStartDelay(startDelay);
    objectAnimator.setRepeatCount(times);
    objectAnimator.setInterpolator(new LinearInterpolator());
    objectAnimator.start();
    return objectAnimator;
}
 
Example 3
Source File: RippleLayout.java    From ripplelayout with MIT License 5 votes vote down vote up
/**
 * 为每个RippleView添加动画效果,并且设置动画延时,每个视图启动动画的时间不同,就会产生波纹
 * 
 * @param rippleView
 * @param i 视图所在的索引
 */
private void addAnimToRippleView(RippleView rippleView, int i) {

    // x轴的缩放动画
    final ObjectAnimator scaleXAnimator = ObjectAnimator.ofFloat(rippleView, "scaleX",
            1.0f, mRippleScale);
    scaleXAnimator.setRepeatCount(ObjectAnimator.INFINITE);
    scaleXAnimator.setRepeatMode(ObjectAnimator.RESTART);
    scaleXAnimator.setStartDelay(i * mAnimDelay);
    scaleXAnimator.setDuration(mAnimDuration);
    mAnimatorList.add(scaleXAnimator);

    // y轴的缩放动画
    final ObjectAnimator scaleYAnimator = ObjectAnimator.ofFloat(rippleView, "scaleY",
            1.0f, mRippleScale);
    scaleYAnimator.setRepeatMode(ObjectAnimator.RESTART);
    scaleYAnimator.setRepeatCount(ObjectAnimator.INFINITE);
    scaleYAnimator.setStartDelay(i * mAnimDelay);
    scaleYAnimator.setDuration(mAnimDuration);
    mAnimatorList.add(scaleYAnimator);

    // 颜色的alpha渐变动画
    final ObjectAnimator alphaAnimator = ObjectAnimator.ofFloat(rippleView, "alpha", 1.0f,
            0f);
    alphaAnimator.setRepeatMode(ObjectAnimator.RESTART);
    alphaAnimator.setRepeatCount(ObjectAnimator.INFINITE);
    alphaAnimator.setDuration(mAnimDuration);
    alphaAnimator.setStartDelay(i * mAnimDelay);
    mAnimatorList.add(alphaAnimator);
}
 
Example 4
Source File: FoldingLayoutActivity.java    From Folding-Android with Apache License 2.0 5 votes vote down vote up
/**
 * Animates the folding view inwards (to a completely folded state) from its
 * current state and then back out to its original state.
 */
public void animateFold() {
	float foldFactor = mFoldLayout.getFoldFactor();

	ObjectAnimator animator = ObjectAnimator.ofFloat(mFoldLayout,
			"foldFactor", foldFactor, 1);
	animator.setRepeatMode(ValueAnimator.REVERSE);
	animator.setRepeatCount(1);
	animator.setDuration(FOLD_ANIMATION_DURATION);
	animator.setInterpolator(new AccelerateInterpolator());
	animator.start();
}