Example usage for android.view.animation AnticipateOvershootInterpolator AnticipateOvershootInterpolator

List of usage examples for android.view.animation AnticipateOvershootInterpolator AnticipateOvershootInterpolator

Introduction

In this page you can find the example usage for android.view.animation AnticipateOvershootInterpolator AnticipateOvershootInterpolator.

Prototype

public AnticipateOvershootInterpolator() 

Source Link

Usage

From source file:com.google.android.apps.santatracker.village.Village.java

private void setIsDay(final boolean isDay, boolean smoothTransition) {
    ObjectAnimator sunAnim = ObjectAnimator.ofInt(this, "sunOffset", sunOffset, isDay ? 0 : mViewHeight);
    sunAnim.setInterpolator(new AnticipateOvershootInterpolator());
    sunAnim.setDuration(smoothTransition ? ImageWithAlphaAndSize.ANIM_DURATION : 0);
    sunAnim.addListener(new Animator.AnimatorListener() {
        @Override// w w  w.ja  va  2 s. co m
        public void onAnimationStart(Animator animation) {
            if (isDay) {
                mImageSun.setAlpha(ImageWithAlphaAndSize.OPAQUE);
            }
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            if (!isDay) {
                mImageSun.setAlpha(ImageWithAlphaAndSize.INVISIBLE);
            }
        }

        @Override
        public void onAnimationCancel(Animator animation) {
        }

        @Override
        public void onAnimationRepeat(Animator animation) {
        }
    });

    AnimatorSet dayAnims = new AnimatorSet();
    dayAnims.playTogether(
            // Day values
            mImageSkyDay.fadeTransition(isDay, smoothTransition),
            mImageMountainsDay.fadeTransition(isDay, smoothTransition),
            mPaintMountainsDay.fadeTransition(isDay, smoothTransition));

    ObjectAnimator moonAnim = ObjectAnimator.ofInt(this, "moonOffset", moonOffset, isDay ? -mViewHeight : 0);
    moonAnim.setInterpolator(new AnticipateOvershootInterpolator());
    moonAnim.setDuration(smoothTransition ? ImageWithAlphaAndSize.ANIM_DURATION : 0);
    moonAnim.addListener(new Animator.AnimatorListener() {
        @Override
        public void onAnimationStart(Animator animation) {
            if (!isDay) {
                mImageMoon.setAlpha(ImageWithAlphaAndSize.OPAQUE);
            }
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            if (isDay) {
                mImageMoon.setAlpha(ImageWithAlphaAndSize.INVISIBLE);
            }
        }

        @Override
        public void onAnimationCancel(Animator animation) {
        }

        @Override
        public void onAnimationRepeat(Animator animation) {
        }
    });

    AnimatorSet nightAnims = new AnimatorSet();
    nightAnims.playTogether(
            // Night values
            mImageSkyNight.fadeTransition(!isDay, !isDay && smoothTransition),
            mImageMountainsNight.fadeTransition(!isDay, !isDay && smoothTransition),
            mPaintMountainsNight.fadeTransition(!isDay, !isDay && smoothTransition));
    // When going to the day, delay night animation till after day time has kicked in
    if (isDay) {
        nightAnims.setStartDelay(ImageWithAlphaAndSize.ANIM_DURATION);
    }

    mFinalAnimations = nightAnims;

    sunAnim.start();
    dayAnims.start();
    moonAnim.start();
    nightAnims.start();
}

From source file:self.philbrown.droidQuery.$.java

/**
 * This reusable chunk of code can set up the given animation using the given animation options
 * @param options the options used to manipulate how the animation behaves
 * @return the container for placing views that will be animated using the given options
 *//*from www .ja v  a 2  s . c o  m*/
private AnimatorSet animationWithOptions(final AnimationOptions options, List<Animator> animators) {
    AnimatorSet animation = new AnimatorSet();
    animation.playTogether(animators);
    animation.setDuration(options.duration());
    animation.addListener(new AnimatorListener() {

        @Override
        public void onAnimationCancel(Animator animation) {
            if (options.fail() != null)
                options.fail().invoke($.this);
            if (options.complete() != null)
                options.complete().invoke($.this);
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            if (options.success() != null)
                options.success().invoke($.this);
            if (options.complete() != null)
                options.complete().invoke($.this);
        }

        @Override
        public void onAnimationRepeat(Animator animation) {
        }

        @Override
        public void onAnimationStart(Animator animation) {
        }

    });
    Interpolator interpolator = null;
    if (options.easing() == null)
        options.easing(Easing.LINEAR);
    final Easing easing = options.easing();
    switch (easing) {
    case ACCELERATE: {
        interpolator = new AccelerateInterpolator();
        break;
    }
    case ACCELERATE_DECELERATE: {
        interpolator = new AccelerateDecelerateInterpolator();
        break;
    }
    case ANTICIPATE: {
        interpolator = new AnticipateInterpolator();
        break;
    }
    case ANTICIPATE_OVERSHOOT: {
        interpolator = new AnticipateOvershootInterpolator();
        break;
    }
    case BOUNCE: {
        interpolator = new BounceInterpolator();
        break;
    }
    case DECELERATE: {
        interpolator = new DecelerateInterpolator();
        break;
    }
    case OVERSHOOT: {
        interpolator = new OvershootInterpolator();
        break;
    }
    //linear is default.
    case LINEAR:
    default:
        interpolator = new LinearInterpolator();
        break;
    }

    //allow custom interpolator
    if (options.specialEasing() != null)
        interpolator = options.specialEasing();

    animation.setInterpolator(interpolator);

    return animation;
}