Example usage for android.animation Animator setDuration

List of usage examples for android.animation Animator setDuration

Introduction

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

Prototype

public abstract Animator setDuration(long duration);

Source Link

Document

Sets the duration of the animation.

Usage

From source file:Main.java

private static void setBatchTiming(long millis, long startDelay, Animator... anims) {
    for (Animator a : anims) {
        a.setDuration(millis);
        a.setStartDelay(startDelay);/*  www  .  j a  v  a 2  s . c  om*/
    }
}

From source file:Main.java

private static Animator setRepeatableAnim(Activity activity, View target, final int duration, int animRes) {
    final Animator anim = AnimatorInflater.loadAnimator(activity, animRes);
    anim.setDuration(duration);
    anim.setTarget(target);//w w  w  .  j a v a  2 s  . c o  m
    return anim;
}

From source file:Main.java

/**
 * Animator to animate X scale of the view. Y scale is constant
 *
 * @param view View to be animated//from w  w w.  j a  v a  2s .c  om
 * @param pivotX x coordinate of the pivot
 * @param pivotY y coordinate of the pivot
 * @param fromScale initial scale
 * @param toScale final scale
 * @param duration animation duration in milliseconds
 * @return Animator Object
 */
@NonNull
public static Animator scaleX(@NonNull View view, int pivotX, int pivotY, float fromScale, float toScale,
        int duration) {
    view.setPivotX(pivotX);
    view.setPivotY(pivotY);
    Animator animator = ObjectAnimator.ofFloat(view, "scaleX", fromScale, toScale);
    animator.setDuration(duration);
    return animator;
}

From source file:Main.java

/**
 * Animator to animate Y scale of the view. X scale is constant
 *
 * @param view View to be animated//from www  .j a v  a  2  s.  c o  m
 * @param pivotX x coordinate of the pivot
 * @param pivotY y coordinate of the pivot
 * @param fromScale initial scale
 * @param toScale final scale
 * @param duration animation duration in milliseconds
 * @return Animator Object
 */
@NonNull
public static Animator scaleY(@NonNull View view, int pivotX, int pivotY, float fromScale, float toScale,
        int duration) {
    view.setPivotX(pivotX);
    view.setPivotY(pivotY);
    Animator animator = ObjectAnimator.ofFloat(view, "scaleY", fromScale, toScale);
    animator.setDuration(duration);
    return animator;
}

From source file:Main.java

@TargetApi(21)
public static Animator circleReveal(View v, int centerX, int centerY, float startRadius, float endRadius,
        int duration) {
    Animator anim = ViewAnimationUtils.createCircularReveal(v, centerX, centerY, startRadius, endRadius);
    anim.setDuration(duration);
    anim.setInterpolator(mAccelerateInterpolator);
    anim.start();//from   w  w w .j  av  a 2  s.c om
    return anim;
}

From source file:Main.java

public static void showRevealEffect(final View v, int centerX, int centerY,
        @Nullable Animator.AnimatorListener lis) {

    v.setVisibility(View.VISIBLE);

    int finalRadius = Math.max(v.getWidth(), v.getHeight());

    Animator anim = ViewAnimationUtils.createCircularReveal(v, centerX, centerY, 0, finalRadius);

    anim.setDuration(REVEAL_DURATION);

    if (lis != null)
        anim.addListener(lis);/*from w ww  . j av  a 2  s.  c o  m*/

    anim.start();
}

From source file:Main.java

/**
 * Circular Reveal Animation/*from ww w  .jav  a 2 s  .  com*/
 * @param view View to be animated
 * @param cx x coordinate of the center of the circle
 * @param cy y coordinate of the center of the circle
 * @param startRadius initial circle radius
 * @param finalRadius final circle radius
 * @param duration animation duration in milliseconds
 * @return Animator Object
 */
@NonNull
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static Animator reveal(@NonNull final View view, int cx, int cy, int startRadius, int finalRadius,
        int duration) {
    Animator animator = ViewAnimationUtils.createCircularReveal(view, cx, cy, startRadius, finalRadius);
    animator.setDuration(duration);
    return animator;
}

From source file:Main.java

public static void showRevealEFfect(final View v, int centerX, int centerY, Animator.AnimatorListener lis) {

    v.setVisibility(View.VISIBLE);

    int height = v.getHeight();

    Animator anim = ViewAnimationUtils.createCircularReveal(v, centerX, centerY, 0, height);

    anim.setDuration(350);

    anim.addListener(lis);/*from  ww w  .  j ava 2  s  .c  o  m*/
    anim.start();
}

From source file:Main.java

public static void startActivity(final Activity thisActivity, final Intent intent, final View triggerView,
        int colorOrImageRes, final long durationMills) {
    int[] location = new int[2];
    triggerView.getLocationInWindow(location);
    final int cx = location[0] + triggerView.getWidth();
    final int cy = location[1] + triggerView.getHeight() + (int) TypedValue
            .applyDimension(TypedValue.COMPLEX_UNIT_DIP, 160, thisActivity.getResources().getDisplayMetrics());
    final ImageView view = new ImageView(thisActivity);
    view.setScaleType(ImageView.ScaleType.CENTER_CROP);
    view.setImageResource(colorOrImageRes);
    final ViewGroup decorView = (ViewGroup) thisActivity.getWindow().getDecorView();
    int w = decorView.getWidth();
    int h = decorView.getHeight();
    decorView.addView(view, w, h);//ww w. j  av  a  2  s  . com
    final int finalRadius = (int) Math.sqrt(w * w + h * h) + 1;
    Animator anim = ViewAnimationUtils.createCircularReveal(view, cx, cy, 0, finalRadius);
    anim.setDuration(durationMills);
    anim.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            thisActivity.startActivity(intent);
            thisActivity.overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
        }
    });
    anim.start();
}

From source file:com.destin.sehaikun.AnimationUtils.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static void reveal(View view, int centerX, int centerY, float startRadius, float endRadius,
        Animator.AnimatorListener listener) {
    Animator animator = ViewAnimationUtils.createCircularReveal(view, centerX, centerY, startRadius, endRadius);
    animator.setDuration(ANIMATION_DURATION_MEDIUM);
    if (listener != null) {
        animator.addListener(listener);/*from w  w  w .jav  a 2s.  c om*/
    }
    animator.start();
}