pause animation - Android android.animation

Android examples for android.animation:Animation

Description

pause animation

Demo Code


//package com.java2s;
import android.animation.Animator;
import android.os.Build;
import java.util.List;

public class Main {
    /**// ww w .  ja  v  a2 s.  c  om
     * pause animation
     *
     * @param animators
     * @return
     */
    public static boolean pause(List<Animator> animators) {
        boolean isPauseCalled = false;
        if (animators != null) {
            for (Animator animator : animators) {
                if (pause(animator)) {
                    isPauseCalled = true;
                }
            }
        }
        return isPauseCalled;
    }

    /**
     * pause
     *
     * @param animator
     */
    public static boolean pause(Animator animator) {
        if (animator != null) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
                if (!animator.isPaused()) {
                    animator.pause();
                    return true;
                }
            }
        }
        return false;
    }

    public static boolean isPaused(List<Animator> animators) {
        if (animators != null && animators.size() > 0) {
            boolean isAllPaused = true;
            for (Animator animator : animators) {
                if (isPaused(animator) == false) {
                    isAllPaused = false;
                }
            }
            return isAllPaused;
        }
        return false;
    }

    public static boolean isPaused(Animator animator) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            return animator != null && animator.isPaused();
        }
        return false;
    }
}

Related Tutorials