Example usage for android.view.animation RotateAnimation setDuration

List of usage examples for android.view.animation RotateAnimation setDuration

Introduction

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

Prototype

public void setDuration(long durationMillis) 

Source Link

Document

How long this animation should last.

Usage

From source file:Main.java

public static RotateAnimation getRotateAnimation(float fromAngle, float toAngle, float pivotX, float pivotY,
        int intDuration, int intRepeatCount, boolean boolFillAfter) {
    RotateAnimation mAnmation = new RotateAnimation(fromAngle, toAngle, Animation.RELATIVE_TO_SELF, pivotX,
            Animation.RELATIVE_TO_SELF, pivotY);
    mAnmation.setDuration(intDuration);
    mAnmation.setFillAfter(boolFillAfter);
    if (intRepeatCount != 1) {
        mAnmation.setRepeatMode(Animation.RESTART);
        mAnmation.setRepeatCount(intRepeatCount);
    }//from  ww  w  . ja  v a2 s. c  om
    // mAnmation.setInterpolator(AnimationUtils.loadInterpolator(mContext,
    // com.webclient.R.anim.bounce_interpolator));
    mAnmation.setInterpolator(new LinearInterpolator());
    return mAnmation;
}

From source file:Main.java

public static void rotateAnimation(View view, float fromDegree, float toDegree) {
    final RotateAnimation rotateAnim = new RotateAnimation(fromDegree, toDegree,
            RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f);

    rotateAnim.setDuration(200);
    rotateAnim.setFillAfter(true);/*  www  . j a va 2 s .com*/
    view.startAnimation(rotateAnim);
}

From source file:Main.java

public static void setRotateAnimation(View view, float fromAngle, float toAngle, float pivotX, float pivotY,
        int intDuration, int intRepeatCount, boolean boolFillAfter) {
    RotateAnimation mAnmation = new RotateAnimation(fromAngle, toAngle, Animation.RELATIVE_TO_SELF, pivotX,
            Animation.RELATIVE_TO_SELF, pivotY);
    mAnmation.setDuration(intDuration);
    mAnmation.setFillAfter(boolFillAfter);
    if (intRepeatCount != 1) {
        mAnmation.setRepeatMode(Animation.RESTART);
        mAnmation.setRepeatCount(intRepeatCount);
    }//from  w  w w  .j  a v a2s.co  m
    // mAnmation.setInterpolator(AnimationUtils.loadInterpolator(mContext,
    // com.webclient.R.anim.bounce_interpolator));
    mAnmation.setInterpolator(new LinearInterpolator());
    view.startAnimation(mAnmation);
}

From source file:Main.java

public static List<Animation> initAnimation(int AnimationType, float fromAlpha, float toAlpha,
        float fromDegress, float toDegress, float pinX, float pinY) {
    List<Animation> animations = new ArrayList<>();
    AlphaAnimation alphaAnimation = new AlphaAnimation(fromAlpha, toAlpha);
    alphaAnimation.setDuration(300);//  w ww . ja v  a 2  s  .  c  o m
    AlphaAnimation exit_alphaAnimation = new AlphaAnimation(toAlpha, fromAlpha);
    exit_alphaAnimation.setDuration(300);
    OvershootInterpolator overshootInterpolator = new OvershootInterpolator(3.5f);
    RotateAnimation rotateAnimation = new RotateAnimation(fromDegress, toDegress, AnimationType, pinX,
            AnimationType, pinY);
    rotateAnimation.setDuration(300);
    rotateAnimation.setInterpolator(overshootInterpolator);
    rotateAnimation.setFillAfter(true);
    RotateAnimation exit_rotateAnimation = new RotateAnimation(toDegress, fromAlpha, AnimationType, pinX,
            AnimationType, pinY);
    exit_rotateAnimation.setDuration(300);
    exit_rotateAnimation.setInterpolator(overshootInterpolator);
    exit_rotateAnimation.setFillAfter(true);
    animations.add(alphaAnimation);
    animations.add(exit_alphaAnimation);
    animations.add(rotateAnimation);
    animations.add(exit_rotateAnimation);
    return animations;
}

From source file:Main.java

public static AnimationSet RotateAndFadeInAnimation() {

    AlphaAnimation fade_in = new AlphaAnimation(0.2f, 1f);
    fade_in.setDuration(400);/*from  w ww .java2  s .com*/
    fade_in.setStartOffset(0);
    fade_in.setFillAfter(true);

    ScaleAnimation expand = new ScaleAnimation(0.2f, 1, 0.2f, 1, Animation.RELATIVE_TO_SELF, .5f,
            Animation.RELATIVE_TO_SELF, .5f);
    expand.setDuration(500);
    expand.setStartOffset(0);
    expand.setFillAfter(true);

    RotateAnimation rotate = new RotateAnimation(0f, 360f, Animation.RELATIVE_TO_SELF, .5f,
            Animation.RELATIVE_TO_SELF, .5f);
    rotate.setDuration(500);
    rotate.setStartOffset(0);
    // rotate.setInterpolator(new LinearInterpolator());
    rotate.setFillAfter(true);

    AnimationSet Reload = new AnimationSet(true);
    Reload.addAnimation(fade_in);
    Reload.addAnimation(expand);
    Reload.addAnimation(rotate);
    Reload.setInterpolator(new DecelerateInterpolator(1.3f));
    return Reload;
}

From source file:Main.java

public static AnimationSet RotateAndFadeOutAnimation() {
    AlphaAnimation fade_out = new AlphaAnimation(1f, 0.2f);
    fade_out.setDuration(500);/*from  ww  w  .j  av a  2  s.  co  m*/
    fade_out.setStartOffset(0);
    fade_out.setFillAfter(true);

    ScaleAnimation shrink = new ScaleAnimation(1f, 0.2f, 1f, 0.2f, Animation.RELATIVE_TO_SELF, .5f,
            Animation.RELATIVE_TO_SELF, .5f);
    shrink.setDuration(400);
    shrink.setStartOffset(0);
    shrink.setFillAfter(true);

    RotateAnimation rotate = new RotateAnimation(0.0f, 360f, Animation.RELATIVE_TO_SELF, .5f,
            Animation.RELATIVE_TO_SELF, .5f);
    rotate.setDuration(500);
    rotate.setStartOffset(0);
    rotate.setInterpolator(new LinearInterpolator());
    rotate.setFillAfter(true);

    AnimationSet Reload = new AnimationSet(true);
    Reload.addAnimation(fade_out);
    Reload.addAnimation(shrink);
    Reload.addAnimation(rotate);
    Reload.setInterpolator(new AccelerateInterpolator(1.1f));

    return Reload;
}

From source file:Main.java

public static void rotate(final View view, float fromDegrees, float toDegrees, long duration) {
    if (Build.VERSION.SDK_INT >= 12) {
        if (duration == 0)
            view.setRotation(toDegrees);
        else//w  w  w .  j a va  2  s  . co  m
            view.animate().rotation(toDegrees).setDuration(duration).start();
    } else {
        RotateAnimation rotate = new RotateAnimation(fromDegrees, toDegrees, Animation.RELATIVE_TO_SELF, 0.5f,
                Animation.RELATIVE_TO_SELF, 0.5f);
        rotate.setDuration(duration);
        rotate.setFillEnabled(true);
        rotate.setFillBefore(true);
        rotate.setFillAfter(true);
        addAnimation(view, rotate);
    }
}

From source file:org.videolan.vlc.gui.helpers.UiTools.java

public static void fillAboutView(View v) {
    TextView link = (TextView) v.findViewById(R.id.main_link);
    link.setText(Html.fromHtml(VLCApplication.getAppResources().getString(R.string.about_link)));

    String revision = VLCApplication.getAppResources().getString(R.string.build_revision) + " VLC: "
            + VLCApplication.getAppResources().getString(R.string.build_vlc_revision);
    String builddate = VLCApplication.getAppResources().getString(R.string.build_time);
    String builder = VLCApplication.getAppResources().getString(R.string.build_host);

    TextView compiled = (TextView) v.findViewById(R.id.main_compiled);
    compiled.setText(builder + " (" + builddate + ")");
    TextView textview_rev = (TextView) v.findViewById(R.id.main_revision);
    textview_rev.setText(VLCApplication.getAppResources().getString(R.string.revision) + " " + revision + " ("
            + builddate + ") " + BuildConfig.FLAVOR_abi);

    final ImageView logo = (ImageView) v.findViewById(R.id.logo);
    logo.setOnClickListener(new View.OnClickListener() {
        @Override/*from   w  w  w. j  av  a 2s.co  m*/
        public void onClick(View v) {
            AnimationSet anim = new AnimationSet(true);
            RotateAnimation rotate = new RotateAnimation(0f, 360f, Animation.RELATIVE_TO_SELF, 0.5f,
                    Animation.RELATIVE_TO_SELF, 0.5f);
            rotate.setDuration(800);
            rotate.setInterpolator(new DecelerateInterpolator());
            anim.addAnimation(rotate);
            logo.startAnimation(anim);
        }
    });
}

From source file:Main.java

public static void shakeAnimation(final View v) {
    float rotate = 0;
    int c = mCount++ % 5;
    if (c == 0) {
        rotate = DEGREE_0;//  w  w  w  .ja va 2  s  .c o  m
    } else if (c == 1) {
        rotate = DEGREE_1;
    } else if (c == 2) {
        rotate = DEGREE_2;
    } else if (c == 3) {
        rotate = DEGREE_3;
    } else {
        rotate = DEGREE_4;
    }
    final RotateAnimation mra = new RotateAnimation(rotate, -rotate, ICON_WIDTH * mDensity / 2,
            ICON_HEIGHT * mDensity / 2);
    final RotateAnimation mrb = new RotateAnimation(-rotate, rotate, ICON_WIDTH * mDensity / 2,
            ICON_HEIGHT * mDensity / 2);

    mra.setDuration(ANIMATION_DURATION);
    mrb.setDuration(ANIMATION_DURATION);

    mra.setAnimationListener(new AnimationListener() {
        @Override
        public void onAnimationEnd(Animation animation) {
            if (mNeedShake) {
                mra.reset();
                v.startAnimation(mrb);
            }
        }

        @Override
        public void onAnimationRepeat(Animation animation) {

        }

        @Override
        public void onAnimationStart(Animation animation) {

        }

    });

    mrb.setAnimationListener(new AnimationListener() {
        @Override
        public void onAnimationEnd(Animation animation) {
            if (mNeedShake) {
                mrb.reset();
                v.startAnimation(mra);
            }
        }

        @Override
        public void onAnimationRepeat(Animation animation) {

        }

        @Override
        public void onAnimationStart(Animation animation) {

        }

    });
    v.startAnimation(mra);
}

From source file:org.tomahawk.tomahawk_android.utils.AdapterUtils.java

private static RotateAnimation constructRotateAnimation() {
    final RotateAnimation animation = new RotateAnimation(0.0f, 360.0f, RotateAnimation.RELATIVE_TO_SELF, 0.49f,
            RotateAnimation.RELATIVE_TO_SELF, 0.5f);
    animation.setDuration(1500);
    animation.setInterpolator(new LinearInterpolator());
    animation.setRepeatCount(RotateAnimation.INFINITE);
    return animation;
}