Example usage for android.view ViewPropertyAnimator setStartDelay

List of usage examples for android.view ViewPropertyAnimator setStartDelay

Introduction

In this page you can find the example usage for android.view ViewPropertyAnimator setStartDelay.

Prototype

public ViewPropertyAnimator setStartDelay(long startDelay) 

Source Link

Document

Sets the startDelay for the underlying animator that animates the requested properties.

Usage

From source file:Main.java

private static void scaleInternal(final View view, int startScaleValue, int endScaleValue, int durationMs,
        int startDelay, AnimatorListenerAdapter listener, Interpolator interpolator) {
    view.setScaleX(startScaleValue);//w w w. j  a v  a 2s  . c om
    view.setScaleY(startScaleValue);

    final ViewPropertyAnimator animator = view.animate();
    animator.cancel();

    animator.setInterpolator(interpolator).scaleX(endScaleValue).scaleY(endScaleValue).setListener(listener)
            .withLayer();

    if (durationMs != DEFAULT_DURATION) {
        animator.setDuration(durationMs);
    }
    animator.setStartDelay(startDelay);

    animator.start();
}

From source file:Main.java

private static void scaleInternal(final View view, int startScaleValue, int endScaleValue, int durationMs,
        int startDelay, AnimatorListenerAdapter listener, Interpolator interpolator) {
    view.setScaleX(startScaleValue);// w  w w .j a v  a2 s. c o  m
    view.setScaleY(startScaleValue);

    final ViewPropertyAnimator animator = view.animate();
    animator.cancel();

    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
        animator.setInterpolator(interpolator).scaleX(endScaleValue).scaleY(endScaleValue)
                .setListener(listener);
    } else {
        animator.setInterpolator(interpolator).scaleX(endScaleValue).scaleY(endScaleValue).setListener(listener)
                .withLayer();
    }
    if (durationMs != DEFAULT_DURATION) {
        animator.setDuration(durationMs);
    }
    animator.setStartDelay(startDelay);

    animator.start();
}

From source file:me.lizheng.deckview.helpers.DeckChildViewTransform.java

/**
 * Applies this transform to a view.//ww  w  .  j ava2s  .  c  o m
 */
public void applyToTaskView(View v, int duration, Interpolator interp, /*boolean allowLayers,*/
        boolean allowShadows/*, ValueAnimator.AnimatorUpdateListener updateCallback*/) {
    // Check to see if any properties have changed, and update the task view
    if (duration > 0) {
        ViewPropertyAnimator anim = v.animate();
        //            boolean requiresLayers = false;

        // Animate to the final state
        if (hasTranslationYChangedFrom(v.getTranslationY())) {
            anim.translationY(translationY);
        }
        //            if (allowShadows && hasTranslationZChangedFrom(v.getTranslationZ())) {
        //                anim.translationZ(translationZ);
        //            }
        if (hasScaleChangedFrom(v.getScaleX())) {
            anim.scaleX(scale).scaleY(scale);
            //                requiresLayers = true;
        }
        if (hasAlphaChangedFrom(v.getAlpha())) {
            // Use layers if we animate alpha
            anim.alpha(alpha);
            //                requiresLayers = true;
        }
        //            if (requiresLayers && allowLayers) {
        //                anim.withLayer();
        //            }
        //            if (updateCallback != null) {
        //                anim.setUpdateListener(updateCallback);
        //            } else {
        //                anim.setUpdateListener(null);
        //            }
        anim.setStartDelay(startDelay).setDuration(duration).setInterpolator(interp).start();
    } else {
        // Set the changed properties
        if (hasTranslationYChangedFrom(v.getTranslationY())) {
            v.setTranslationY(translationY);
        }
        if (allowShadows && hasTranslationZChangedFrom(ViewCompat.getTranslationZ(v))) {
            ViewCompat.setTranslationZ(v, translationZ);
        }
        if (hasScaleChangedFrom(v.getScaleX())) {
            v.setScaleX(scale);
            v.setScaleY(scale);
        }
        if (hasAlphaChangedFrom(v.getAlpha())) {
            v.setAlpha(alpha);
        }
    }
}