Example usage for android.animation ObjectAnimator setAutoCancel

List of usage examples for android.animation ObjectAnimator setAutoCancel

Introduction

In this page you can find the example usage for android.animation ObjectAnimator setAutoCancel.

Prototype

public void setAutoCancel(boolean cancel) 

Source Link

Document

autoCancel controls whether an ObjectAnimator will be canceled automatically when any other ObjectAnimator with the same target and properties is started.

Usage

From source file:com.serenegiant.aceparrot.BaseFragment.java

/**
 * 01??(View)??/*from w  ww  . j a  va 2s .  com*/
 * @param target
 * @param startDelay
 */
@SuppressLint("NewApi")
protected final void fadeIn(final View target, final long duration, final long startDelay) {
    //      if (DEBUG) Log.v(TAG, "fadeIn:target=" + target);
    if (target == null)
        return;
    target.clearAnimation();
    target.setVisibility(View.VISIBLE);
    target.setTag(R.id.anim_type, ANIM_FADE_IN); // ???
    target.setScaleX(1.0f);
    target.setScaleY(1.0f);
    target.setAlpha(0.0f);
    final ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(target, "alpha", 0f, 1f);
    objectAnimator.addListener(mAnimatorListener);
    if (BuildCheck.isJellyBeanMR2())
        objectAnimator.setAutoCancel(true); // API >= 18 ??????Animator????
    objectAnimator.setDuration(duration > 0 ? duration : 500); // 0.5???
    objectAnimator.setStartDelay(startDelay > 0 ? startDelay : 0); // ???
    objectAnimator.start(); // 
}

From source file:com.serenegiant.aceparrot.BaseFragment.java

/**
 * 10??(View)??//from ww w  .  ja v  a 2  s.co  m
 * @param target
 * @param startDelay
 */
@SuppressLint("NewApi")
protected final void fadeOut(final View target, final long duration, final long startDelay) {
    //      if (DEBUG) Log.v(TAG, "fadeOut,target=" + target);
    if (target == null)
        return;
    target.clearAnimation();
    if (target.getVisibility() == View.VISIBLE) {
        target.setTag(R.id.anim_type, ANIM_FADE_OUT); // ??
        target.setScaleX(1.0f);
        target.setScaleY(1.0f);
        target.setAlpha(1.0f);
        final ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(target, "alpha", 1f, 0f);
        objectAnimator.addListener(mAnimatorListener);
        if (BuildCheck.isAndroid4_3())
            objectAnimator.setAutoCancel(true); // API >= 18 ??????Animator????
        objectAnimator.setDuration(duration > 0 ? duration : 500); // 0.5???
        objectAnimator.setStartDelay(startDelay > 0 ? startDelay : 0); // ???
        objectAnimator.start(); // 
    }
}

From source file:com.serenegiant.aceparrot.BaseFragment.java

/**
 * start?stop????/*from  w w w . java 2s .c o m*/
 * @param target
 * @param type ???????
 * @param start [0.0f-1.0f]
 * @param stop  [0.0f-1.0f]
 * @param duration []
 * @param startDelay []
 */
@SuppressLint("NewApi")
protected final void alphaAnimation(final View target, final int type, final float start, final float stop,
        final long duration, final long startDelay, final AnimationCallback callback) {
    //      if (DEBUG) Log.v(TAG, "fadeOut,target=" + target);
    if (target == null)
        return;
    target.clearAnimation();
    if (target.getVisibility() == View.VISIBLE) {
        target.setTag(R.id.anim_type, type);
        target.setTag(R.id.anim_callback, callback);
        target.setScaleX(1.0f);
        target.setScaleY(1.0f);
        target.setAlpha(start);
        final ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(target, "alpha", start, stop);
        objectAnimator.addListener(mAnimatorListener);
        if (BuildCheck.isAndroid4_3())
            objectAnimator.setAutoCancel(true); // API >= 18 ??????Animator????
        objectAnimator.setDuration(duration > 0 ? duration : 500); // 0.5???
        objectAnimator.setStartDelay(startDelay > 0 ? startDelay : 0); // ???
        objectAnimator.start(); // 
    }
}

From source file:com.serenegiant.aceparrot.BaseFragment.java

/**
 * 01??(View)??/*from w w w. jav  a 2s  .  co m*/
 * @param target
 * @param startDelay
 */
@SuppressLint("NewApi")
protected final void zoomIn(final View target, final long duration, final long startDelay) {
    //      if (DEBUG) Log.v(TAG, "zoomIn:target=" + target);
    if (target == null)
        return;
    target.clearAnimation();
    target.setVisibility(View.VISIBLE);
    target.setTag(R.id.anim_type, ANIM_ZOOM_IN); // ???
    target.setScaleX(0.0f);
    target.setScaleY(0.0f);
    target.setAlpha(1.0f);
    final PropertyValuesHolder scale_x = PropertyValuesHolder.ofFloat("scaleX", 0.01f, 1f);
    final PropertyValuesHolder scale_y = PropertyValuesHolder.ofFloat("scaleY", 0.01f, 1f);
    final ObjectAnimator objectAnimator = ObjectAnimator.ofPropertyValuesHolder(target, scale_x, scale_y);
    objectAnimator.addListener(mAnimatorListener);
    if (BuildCheck.isJellyBeanMR2())
        objectAnimator.setAutoCancel(true); // API >= 18 ??????Animator????
    objectAnimator.setDuration(duration > 0 ? duration : 500); // 0.5???
    objectAnimator.setStartDelay(startDelay > 0 ? startDelay : 0); // ???
    objectAnimator.start(); // 
}

From source file:com.serenegiant.aceparrot.BaseFragment.java

/**
 * 10??(View)??//from w  w w .jav  a 2s .  c  o  m
 * @param target
 * @param startDelay
 */
@SuppressLint("NewApi")
protected final void zoomOut(final View target, final long duration, final long startDelay) {
    //      if (DEBUG) Log.v(TAG, "zoomIn:target=" + target);
    if (target == null)
        return;
    target.clearAnimation();
    target.setVisibility(View.VISIBLE);
    target.setTag(R.id.anim_type, ANIM_ZOOM_OUT); // ???
    target.setScaleX(1.0f);
    target.setScaleY(1.0f);
    target.setAlpha(1.0f);
    final PropertyValuesHolder scale_x = PropertyValuesHolder.ofFloat("scaleX", 1f, 0f);
    final PropertyValuesHolder scale_y = PropertyValuesHolder.ofFloat("scaleY", 1f, 0f);
    final ObjectAnimator objectAnimator = ObjectAnimator.ofPropertyValuesHolder(target, scale_x, scale_y);
    objectAnimator.addListener(mAnimatorListener);
    if (BuildCheck.isJellyBeanMR2())
        objectAnimator.setAutoCancel(true); // API >= 18 ??????Animator????
    objectAnimator.setDuration(duration > 0 ? duration : 500); // 0.5???
    objectAnimator.setStartDelay(startDelay > 0 ? startDelay : 0); // ???
    objectAnimator.start(); // 
}