Java Code Examples for android.animation.Animator#isRunning()

The following examples show how to use android.animation.Animator#isRunning() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AnimatedVectorDrawable.java    From ElasticProgressBar with Apache License 2.0 6 votes vote down vote up
@Override
public void start() {
    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 (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            if (!animator.isStarted()) {
                animator.start();
            }
        }else {
            if (!animator.isRunning()) {
                animator.start();
            }
        }
    }
    invalidateSelf();
}
 
Example 2
Source File: CircleIndicator.java    From SuperIndicator with Apache License 2.0 6 votes vote down vote up
private void addIndicator(@DrawableRes int backgroundDrawableId, Animator animator) {
    if (animator.isRunning()) {
        animator.end();
        animator.cancel();
    }

    View Indicator = new View(getContext());
    Indicator.setBackgroundResource(backgroundDrawableId);
    addView(Indicator, mIndicatorWidth, mIndicatorHeight);
    LayoutParams lp = (LayoutParams) Indicator.getLayoutParams();
    lp.leftMargin = mIndicatorMargin;
    lp.rightMargin = mIndicatorMargin;
    Indicator.setLayoutParams(lp);

    animator.setTarget(Indicator);
    animator.start();
}
 
Example 3
Source File: PointIndicator.java    From IndicatorBox with MIT License 6 votes vote down vote up
/**
 * 添加单个指示器
 * @param backgroundResId
 * @param animator
 */
private void addIndicator(@DrawableRes int backgroundResId, Animator animator){
    if (animator.isRunning()){
        animator.end();
        animator.cancel();
    }
    View indicator = new View(getContext());
    indicator.setBackgroundResource(backgroundResId);
    addView(indicator, mIndicatorWidth, mIndicatorHeight);
    LayoutParams lp = (LayoutParams) indicator.getLayoutParams();
    if (mOrientation == LinearLayout.HORIZONTAL){
        lp.leftMargin = mIndicatorMargin;
        lp.rightMargin = mIndicatorMargin;
    }else if (mOrientation == LinearLayout.VERTICAL){
        lp.topMargin = mIndicatorMargin;
        lp.bottomMargin = mIndicatorMargin;
    }
    indicator.setLayoutParams(lp);
    animator.setTarget(indicator);
    animator.start();
}
 
Example 4
Source File: ProgressIndicatorView.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
/**
 * make animation to start or end when target
 * view was be Visible or Gone or Invisible.
 * make animation to cancel when target view
 * be onDetachedFromWindow.
 *
 * @param animStatus
 */
public void setAnimationStatus(AnimStatus animStatus) {
    if (mAnimators == null) {
        return;
    }
    int count = mAnimators.size();
    for (int i = 0; i < count; i++) {
        Animator animator = mAnimators.get(i);
        boolean isRunning = animator.isRunning();
        switch (animStatus) {
            case START:
                if (!isRunning) {
                    animator.start();
                }
                break;
            case END:
                if (isRunning) {
                    animator.end();
                }
                break;
            case CANCEL:
                if (isRunning) {
                    animator.cancel();
                }
                break;
        }
    }
}
 
Example 5
Source File: ProgressView.java    From Nimingban with Apache License 2.0 5 votes vote down vote up
private void startAnimationActually() {
    ArrayList<Animator> animators = mAnimators;
    int N = animators.size();
    for (int i = 0; i < N; i++) {
        Animator animator = animators.get(i);
        if (!animator.isRunning()) {
            animator.start();
        }
    }
}
 
Example 6
Source File: BaseIndicatorController.java    From LazyRecyclerAdapter with MIT License 5 votes vote down vote up
/**
 * make animation to start or end when target
 * view was be Visible or Gone or Invisible.
 * make animation to cancel when target view
 * be onDetachedFromWindow.
 *
 * @param animStatus
 */
public void setAnimationStatus(AnimStatus animStatus) {
    if (mAnimators == null) {
        return;
    }
    int count = mAnimators.size();
    for (int i = 0; i < count; i++) {
        Animator animator = mAnimators.get(i);
        boolean isRunning = animator.isRunning();
        switch (animStatus) {
            case START:
                if (!isRunning) {
                    animator.start();
                }
                break;
            case END:
                if (isRunning) {
                    animator.end();
                }
                break;
            case CANCEL:
                if (isRunning) {
                    animator.cancel();
                }
                break;
        }
    }
}
 
Example 7
Source File: ProgressIndicatorView.java    From 920-text-editor-v2 with Apache License 2.0 5 votes vote down vote up
/**
 * make animation to start or end when target
 * view was be Visible or Gone or Invisible.
 * make animation to cancel when target view
 * be onDetachedFromWindow.
 *
 * @param animStatus
 */
public void setAnimationStatus(AnimStatus animStatus) {
    if (mAnimators == null) {
        return;
    }
    int count = mAnimators.size();
    for (int i = 0; i < count; i++) {
        Animator animator = mAnimators.get(i);
        boolean isRunning = animator.isRunning();
        switch (animStatus) {
            case START:
                if (!isRunning) {
                    animator.start();
                }
                break;
            case END:
                if (isRunning) {
                    animator.end();
                }
                break;
            case CANCEL:
                if (isRunning) {
                    animator.cancel();
                }
                break;
        }
    }
}
 
Example 8
Source File: AnimatedSVGDrawable.java    From SVG-Android with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isRunning() {
    final ArrayList<Animator> animators = mAnimatedSVGState.mAnimators;
    if (animators == null || animators.isEmpty()) {
        return false;
    }
    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;
}
 
Example 9
Source File: CircleIndicator.java    From Android-Application-ZJB with Apache License 2.0 5 votes vote down vote up
private void addIndicator(@DrawableRes int backgroundDrawableId, Animator animator) {
    if (animator.isRunning()) animator.end();

    View Indicator = new View(getContext());
    Indicator.setBackgroundResource(backgroundDrawableId);
    addView(Indicator, mIndicatorWidth, mIndicatorHeight);
    LayoutParams lp = (LayoutParams) Indicator.getLayoutParams();
    lp.leftMargin = mIndicatorMargin;
    lp.rightMargin = mIndicatorMargin;
    Indicator.setLayoutParams(lp);

    animator.setTarget(Indicator);
    animator.start();
}
 
Example 10
Source File: ProgressView.java    From EhViewer with Apache License 2.0 5 votes vote down vote up
public boolean isRunning() {
    ArrayList<Animator> animators = mAnimators;
    int N = animators.size();
    for (int i = 0; i < N; i++) {
        Animator animator = animators.get(i);
        if (animator.isRunning()) {
            return true;
        }
    }
    return false;
}
 
Example 11
Source File: LauncherAnimUtils.java    From LB-Launcher with Apache License 2.0 5 votes vote down vote up
public static void onDestroyActivity() {
    HashSet<Animator> animators = new HashSet<Animator>(sAnimators.keySet());
    for (Animator a : animators) {
        if (a.isRunning()) {
            a.cancel();
        }
        sAnimators.remove(a);
    }
}
 
Example 12
Source File: LauncherAnimUtils.java    From Trebuchet with GNU General Public License v3.0 5 votes vote down vote up
public static void onDestroyActivity() {
    HashSet<Animator> animators = new HashSet<Animator>(sAnimators.keySet());
    for (Animator a : animators) {
        if (a.isRunning()) {
            a.cancel();
        }
        sAnimators.remove(a);
    }
}
 
Example 13
Source File: LauncherAnimUtils.java    From TurboLauncher with Apache License 2.0 5 votes vote down vote up
public static void onDestroyActivity() {
    HashSet<Animator> animators = new HashSet<Animator>(sAnimators.keySet());
    for (Animator a : animators) {
        if (a.isRunning()) {
            a.cancel();
        }
        sAnimators.remove(a);
    }
}
 
Example 14
Source File: BezierPraiseAnimator.java    From kAndroid with Apache License 2.0 5 votes vote down vote up
/**
 * 取消动画
 */
public void cancelAnimation() {
    if (mAnimatorList == null || mAnimatorList.isEmpty()) {
        return;
    }
    for (Animator animator : mAnimatorList) {
        if (animator.isRunning()) {
            animator.cancel();
        }
    }
}
 
Example 15
Source File: SupportAnimatorLollipop.java    From NHentai-android with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean isRunning() {
    Animator a = mNativeAnimator.get();
    return a != null && a.isRunning();
}
 
Example 16
Source File: SupportAnimatorLollipop.java    From RecyclerView-Animation-Demo with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isRunning() {
    Animator a = mAnimator.get();
    return a != null && a.isRunning();
}
 
Example 17
Source File: Transition.java    From Transitions-Everywhere with Apache License 2.0 4 votes vote down vote up
/**
 * 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.
 */
void playTransition(@NonNull 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();
}
 
Example 18
Source File: SupportAnimatorLollipop.java    From WeGit with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isRunning() {
    Animator a = mNativeAnimator.get();
    return a != null && a.isRunning();
}
 
Example 19
Source File: Transition.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
/**
 * 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.
 */
void playTransition(ViewGroup sceneRoot) {
    mStartValuesList = new ArrayList<TransitionValues>();
    mEndValuesList = new ArrayList<TransitionValues>();
    matchStartAndEnd(mStartValues, mEndValues);

    ArrayMap<Animator, AnimationInfo> runningAnimators = getRunningAnimators();
    int numOldAnims = runningAnimators.size();
    WindowId windowId = sceneRoot.getWindowId();
    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() || 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, mStartValuesList, mEndValuesList);
    runAnimators();
}
 
Example 20
Source File: AnimatorUtil.java    From VideoOS-Android-SDK with GNU General Public License v3.0 2 votes vote down vote up
/**
 * 是否运行
 *
 * @param animator
 * @return
 */
public static boolean isRunning(Animator animator) {
    return animator != null && animator.isRunning();
}