Example usage for android.view.animation Animation START_ON_FIRST_FRAME

List of usage examples for android.view.animation Animation START_ON_FIRST_FRAME

Introduction

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

Prototype

int START_ON_FIRST_FRAME

To view the source code for android.view.animation Animation START_ON_FIRST_FRAME.

Click Source Link

Document

Can be used as the start time to indicate the start time should be the current time when #getTransformation(long,Transformation) is invoked for the first animation frame.

Usage

From source file:Main.java

public static RotateAnimation getDialogRotateAnimation2() {
    RotateAnimation mAnim = new RotateAnimation(0, 360, Animation.RESTART, 0.5f, Animation.RESTART, 0.5f);
    mAnim.setDuration(2000);/*from www .j ava  2  s.c om*/
    mAnim.setRepeatCount(Animation.INFINITE);
    mAnim.setRepeatMode(Animation.RESTART);
    mAnim.setStartTime(Animation.START_ON_FIRST_FRAME);
    return mAnim;
}

From source file:Main.java

public static Animation createForeverRotationAnimation() {
    Animation mRotateAnimation = new RotateAnimation(0, 1080, Animation.RESTART, 0.5f, Animation.RESTART, 0.5f);
    mRotateAnimation.setInterpolator(new LinearInterpolator());
    mRotateAnimation.setRepeatCount(Animation.INFINITE);
    mRotateAnimation.setRepeatMode(Animation.RESTART);
    mRotateAnimation.setStartTime(Animation.START_ON_FIRST_FRAME);
    return mRotateAnimation;
}

From source file:Main.java

public static Animation createForeverReverseRotationAnimation() {
    Animation mRotateAnimation = new RotateAnimation(720, 0, Animation.RESTART, 0.5f, Animation.RESTART, 0.5f);
    mRotateAnimation.setInterpolator(new LinearInterpolator());
    mRotateAnimation.setRepeatCount(Animation.INFINITE);
    mRotateAnimation.setRepeatMode(Animation.RESTART);
    mRotateAnimation.setStartTime(Animation.START_ON_FIRST_FRAME);
    return mRotateAnimation;
}

From source file:Main.java

public static void addAnimation(View view, Animation animation, boolean first) {
    Animation previousAnimation = view.getAnimation();
    if (previousAnimation == null || previousAnimation.getClass() == animation.getClass()) {
        if (animation.getStartTime() == Animation.START_ON_FIRST_FRAME)
            view.startAnimation(animation);
        else/* ww  w  .j ava  2 s .  c  o m*/
            view.setAnimation(animation);
        return;
    }

    if (!(previousAnimation instanceof AnimationSet)) {
        AnimationSet newSet = new AnimationSet(false);
        newSet.addAnimation(previousAnimation);
        previousAnimation = newSet;
    }

    // Remove old of same type
    //
    AnimationSet set = (AnimationSet) previousAnimation;
    for (int i = 0; i < set.getAnimations().size(); i++) {
        Animation anim = set.getAnimations().get(i);
        if (anim.getClass() == animation.getClass()) {
            set.getAnimations().remove(i);
            break;
        }
    }

    // Add this (first if it is a scale animation ,else at end)
    if (animation instanceof ScaleAnimation || first) {
        set.getAnimations().add(0, animation);
    } else {
        set.getAnimations().add(animation);
    }

    animation.startNow();
    view.setAnimation(set);
}

From source file:Main.java

static void addAnimation(View view, Animation animation, boolean first) {
    Animation previousAnimation = view.getAnimation();
    if (previousAnimation == null || previousAnimation.getClass() == animation.getClass()) {
        if (animation.getStartTime() == Animation.START_ON_FIRST_FRAME)
            view.startAnimation(animation);
        else/*ww w  .j  av a 2s.  com*/
            view.setAnimation(animation);
        return;
    }

    if (!(previousAnimation instanceof AnimationSet)) {
        AnimationSet newSet = new AnimationSet(false);
        newSet.addAnimation(previousAnimation);
        previousAnimation = newSet;
    }

    // Remove old of same type
    //
    AnimationSet set = (AnimationSet) previousAnimation;
    for (int i = 0; i < set.getAnimations().size(); i++) {
        Animation anim = set.getAnimations().get(i);
        if (anim.getClass() == animation.getClass()) {
            set.getAnimations().remove(i);
            break;
        }
    }

    // Add this (first if it is a scale animation ,else at end)
    if (animation instanceof ScaleAnimation || first) {
        set.getAnimations().add(0, animation);
    } else {
        set.getAnimations().add(animation);
    }

    animation.startNow();
    view.setAnimation(set);
}

From source file:com.actionbarsherlock.internal.widget.IcsProgressBar.java

/**
 * <p>Start the indeterminate progress animation.</p>
 *//*from  w w w.  j  av a 2s  .com*/
void startAnimation() {
    if (getVisibility() != VISIBLE) {
        return;
    }

    if (mIndeterminateDrawable instanceof Animatable) {
        mShouldStartAnimationDrawable = true;
        mAnimation = null;
    } else {
        if (mInterpolator == null) {
            mInterpolator = new LinearInterpolator();
        }

        mTransformation = new Transformation();
        mAnimation = new AlphaAnimation(0.0f, 1.0f);
        mAnimation.setRepeatMode(mBehavior);
        mAnimation.setRepeatCount(Animation.INFINITE);
        mAnimation.setDuration(mDuration);
        mAnimation.setInterpolator(mInterpolator);
        mAnimation.setStartTime(Animation.START_ON_FIRST_FRAME);
    }
    postInvalidate();
}