Example usage for android.animation Animator isRunning

List of usage examples for android.animation Animator isRunning

Introduction

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

Prototype

public abstract boolean isRunning();

Source Link

Document

Returns whether this Animator is currently running (having been started and gone past any initial startDelay period and not yet ended).

Usage

From source file:com.jmstudios.redmoon.presenter.ScreenFilterPresenter.java

private void cancelRunningAnimator(Animator animator) {
    if (animator != null && animator.isRunning()) {
        animator.cancel();
    }
}

From source file:android.support.graphics.drawable.AnimatedVectorDrawableCompat.java

private boolean isStarted() {
    final ArrayList<Animator> animators = mAnimatedVectorState.mAnimators;
    if (animators == null) {
        return false;
    }/* w w w  . j a v a2 s  .c  o m*/
    final int size = animators.size();
    for (int i = 0; i < size; i++) {
        final Animator animator = animators.get(i);
        if (animator.isRunning()) {
            return true;
        }
    }
    return false;
}

From source file:android.support.graphics.drawable.AnimatedVectorDrawableCompat.java

@Override
public boolean isRunning() {
    if (mDelegateDrawable != null) {
        return ((AnimatedVectorDrawable) mDelegateDrawable).isRunning();
    }//from   w  w w  .  ja  va2  s .  co m
    final ArrayList<Animator> animators = mAnimatedVectorState.mAnimators;
    final int size = animators.size();
    for (int i = 0; i < size; i++) {
        final Animator animator = animators.get(i);
        if (animator.isRunning()) {
            return true;
        }
    }
    return false;
}

From source file:android.transitions.everywhere.Transition.java

/**
 * Called by TransitionManager to play the transition. This calls
 * createAnimators() to set things up and create all of the animations and then
 * runAnimations() to actually start the animations.
 *///from   w  ww .ja v a2  s .c  o m
void playTransition(ViewGroup sceneRoot) {
    mStartValuesList = new ArrayList<TransitionValues>();
    mEndValuesList = new ArrayList<TransitionValues>();
    matchStartAndEnd(mStartValues, mEndValues);

    ArrayMap<Animator, AnimationInfo> runningAnimators = getRunningAnimators();
    int numOldAnims = runningAnimators.size();
    Object windowId = ViewUtils.getWindowId(sceneRoot);
    for (int i = numOldAnims - 1; i >= 0; i--) {
        Animator anim = runningAnimators.keyAt(i);
        if (anim != null) {
            AnimationInfo oldInfo = runningAnimators.get(anim);
            if (oldInfo != null && oldInfo.view != null && oldInfo.windowId == windowId) {
                TransitionValues oldValues = oldInfo.values;
                View oldView = oldInfo.view;
                TransitionValues startValues = getTransitionValues(oldView, true);
                TransitionValues endValues = getMatchedTransitionValues(oldView, true);
                boolean cancel = (startValues != null || endValues != null)
                        && oldInfo.transition.areValuesChanged(oldValues, endValues);
                if (cancel) {
                    if (anim.isRunning() || AnimatorUtils.isAnimatorStarted(anim)) {
                        if (DBG) {
                            Log.d(LOG_TAG, "Canceling anim " + anim);
                        }
                        anim.cancel();
                    } else {
                        if (DBG) {
                            Log.d(LOG_TAG, "removing anim from info list: " + anim);
                        }
                        runningAnimators.remove(anim);
                    }
                }
            }
        }
    }

    createAnimators(sceneRoot, mStartValues, mEndValues, mStartValuesList, mEndValuesList);
    runAnimators();
}

From source file:android.support.transition.TransitionPort.java

/**
 * Called by TransitionManager to play the transition. This calls
 * createAnimators() to set things up and create all of the animations and then
 * runAnimations() to actually start the animations.
 *///from w  ww.  j  a  v  a  2s  . com
void playTransition(ViewGroup sceneRoot) {
    ArrayMap<Animator, AnimationInfo> runningAnimators = getRunningAnimators();
    int numOldAnims = runningAnimators.size();
    for (int i = numOldAnims - 1; i >= 0; i--) {
        Animator anim = runningAnimators.keyAt(i);
        if (anim != null) {
            AnimationInfo oldInfo = runningAnimators.get(anim);
            if (oldInfo != null && oldInfo.view != null
                    && oldInfo.view.getContext() == sceneRoot.getContext()) {
                boolean cancel = false;
                TransitionValues oldValues = oldInfo.values;
                View oldView = oldInfo.view;
                TransitionValues newValues = mEndValues.viewValues != null ? mEndValues.viewValues.get(oldView)
                        : null;
                if (newValues == null) {
                    newValues = mEndValues.idValues.get(oldView.getId());
                }
                if (oldValues != null) {
                    // if oldValues null, then transition didn't care to stash values,
                    // and won't get canceled
                    if (newValues != null) {
                        for (String key : oldValues.values.keySet()) {
                            Object oldValue = oldValues.values.get(key);
                            Object newValue = newValues.values.get(key);
                            if (oldValue != null && newValue != null && !oldValue.equals(newValue)) {
                                cancel = true;
                                if (DBG) {
                                    Log.d(LOG_TAG, "Transition.playTransition: " + "oldValue != newValue for "
                                            + key + ": old, new = " + oldValue + ", " + newValue);
                                }
                                break;
                            }
                        }
                    }
                }
                if (cancel) {
                    if (anim.isRunning() || anim.isStarted()) {
                        if (DBG) {
                            Log.d(LOG_TAG, "Canceling anim " + anim);
                        }
                        anim.cancel();
                    } else {
                        if (DBG) {
                            Log.d(LOG_TAG, "removing anim from info list: " + anim);
                        }
                        runningAnimators.remove(anim);
                    }
                }
            }
        }
    }

    createAnimators(sceneRoot, mStartValues, mEndValues);
    runAnimators();
}

From source file:com.transitionseverywhere.Transition.java

/**
 * Called by TransitionManager to play the transition. This calls
 * createAnimators() to set things up and create all of the animations and then
 * runAnimations() to actually start the animations.
 *///  ww w. j a v  a2  s  . co m
void playTransition(ViewGroup sceneRoot) {
    mStartValuesList = new ArrayList<TransitionValues>();
    mEndValuesList = new ArrayList<TransitionValues>();
    matchStartAndEnd(mStartValues, mEndValues);

    ArrayMap<Animator, AnimationInfo> runningAnimators = getRunningAnimators();
    synchronized (sRunningAnimators) {
        int numOldAnims = runningAnimators.size();
        Object windowId = ViewUtils.getWindowId(sceneRoot);
        for (int i = numOldAnims - 1; i >= 0; i--) {
            Animator anim = runningAnimators.keyAt(i);
            if (anim != null) {
                AnimationInfo oldInfo = runningAnimators.get(anim);
                if (oldInfo != null && oldInfo.view != null && oldInfo.windowId == windowId) {
                    TransitionValues oldValues = oldInfo.values;
                    View oldView = oldInfo.view;
                    TransitionValues startValues = getTransitionValues(oldView, true);
                    TransitionValues endValues = getMatchedTransitionValues(oldView, true);
                    if (startValues == null && endValues == null) {
                        endValues = mEndValues.viewValues.get(oldView);
                    }
                    boolean cancel = (startValues != null || endValues != null)
                            && oldInfo.transition.isTransitionRequired(oldValues, endValues);
                    if (cancel) {
                        if (anim.isRunning() || AnimatorUtils.isAnimatorStarted(anim)) {
                            if (DBG) {
                                Log.d(LOG_TAG, "Canceling anim " + anim);
                            }
                            anim.cancel();
                        } else {
                            if (DBG) {
                                Log.d(LOG_TAG, "removing anim from info list: " + anim);
                            }
                            runningAnimators.remove(anim);
                        }
                    }
                }
            }
        }
    }

    createAnimators(sceneRoot, mStartValues, mEndValues, mStartValuesList, mEndValuesList);
    runAnimators();
}

From source file:android.support.transition.Transition.java

/**
 * Called by TransitionManager to play the transition. This calls
 * createAnimators() to set things up and create all of the animations and then
 * runAnimations() to actually start the animations.
 *///from   ww  w.  j a v  a  2  s. c  om
void playTransition(ViewGroup sceneRoot) {
    ArrayMap<Animator, AnimationInfo> runningAnimators = getRunningAnimators();
    int numOldAnims = runningAnimators.size();
    for (int i = numOldAnims - 1; i >= 0; i--) {
        Animator anim = runningAnimators.keyAt(i);
        if (anim != null) {
            AnimationInfo oldInfo = runningAnimators.get(anim);
            if (oldInfo != null) {
                boolean cancel = false;
                TransitionValues oldValues = oldInfo.values;
                View oldView = oldInfo.view;
                TransitionValues newValues = mEndValues.viewValues != null ? mEndValues.viewValues.get(oldView)
                        : null;
                if (newValues == null) {
                    newValues = mEndValues.idValues.get(oldView.getId());
                }
                if (oldValues != null) {
                    // if oldValues null, then transition didn't care to stash values,
                    // and won't get canceled
                    if (newValues != null) {
                        for (String key : oldValues.values.keySet()) {
                            Object oldValue = oldValues.values.get(key);
                            Object newValue = newValues.values.get(key);
                            if (oldValue != null && newValue != null && !oldValue.equals(newValue)) {
                                cancel = true;
                                if (DBG) {
                                    Log.d(LOG_TAG, "Transition.playTransition: " + "oldValue != newValue for "
                                            + key + ": old, new = " + oldValue + ", " + newValue);
                                }
                                break;
                            }
                        }
                    }
                }
                if (cancel) {
                    if (anim.isRunning() || anim.isStarted()) {
                        if (DBG) {
                            Log.d(LOG_TAG, "Canceling anim " + anim);
                        }
                        anim.cancel();
                    } else {
                        if (DBG) {
                            Log.d(LOG_TAG, "removing anim from info list: " + anim);
                        }
                        runningAnimators.remove(anim);
                    }
                }
            }
        }
    }

    createAnimators(sceneRoot, mStartValues, mEndValues);
    runAnimators();
}