Example usage for android.view.animation Animation getClass

List of usage examples for android.view.animation Animation getClass

Introduction

In this page you can find the example usage for android.view.animation Animation getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:Main.java

public static void addAnimation(View view, Animation animation, boolean first) {
    Animation previousAnimation = view.getAnimation();
    if (previousAnimation == null || previousAnimation.getClass() == animation.getClass()) {
        if (animation.getStartTime() == Animation.START_ON_FIRST_FRAME)
            view.startAnimation(animation);
        else//from w  ww. ja  v a  2 s  .  co  m
            view.setAnimation(animation);
        return;
    }

    if (!(previousAnimation instanceof AnimationSet)) {
        AnimationSet newSet = new AnimationSet(false);
        newSet.addAnimation(previousAnimation);
        previousAnimation = newSet;
    }

    // Remove old of same type
    //
    AnimationSet set = (AnimationSet) previousAnimation;
    for (int i = 0; i < set.getAnimations().size(); i++) {
        Animation anim = set.getAnimations().get(i);
        if (anim.getClass() == animation.getClass()) {
            set.getAnimations().remove(i);
            break;
        }
    }

    // Add this (first if it is a scale animation ,else at end)
    if (animation instanceof ScaleAnimation || first) {
        set.getAnimations().add(0, animation);
    } else {
        set.getAnimations().add(animation);
    }

    animation.startNow();
    view.setAnimation(set);
}

From source file:Main.java

static void addAnimation(View view, Animation animation, boolean first) {
    Animation previousAnimation = view.getAnimation();
    if (previousAnimation == null || previousAnimation.getClass() == animation.getClass()) {
        if (animation.getStartTime() == Animation.START_ON_FIRST_FRAME)
            view.startAnimation(animation);
        else//from w  ww. java2  s .  co  m
            view.setAnimation(animation);
        return;
    }

    if (!(previousAnimation instanceof AnimationSet)) {
        AnimationSet newSet = new AnimationSet(false);
        newSet.addAnimation(previousAnimation);
        previousAnimation = newSet;
    }

    // Remove old of same type
    //
    AnimationSet set = (AnimationSet) previousAnimation;
    for (int i = 0; i < set.getAnimations().size(); i++) {
        Animation anim = set.getAnimations().get(i);
        if (anim.getClass() == animation.getClass()) {
            set.getAnimations().remove(i);
            break;
        }
    }

    // Add this (first if it is a scale animation ,else at end)
    if (animation instanceof ScaleAnimation || first) {
        set.getAnimations().add(0, animation);
    } else {
        set.getAnimations().add(animation);
    }

    animation.startNow();
    view.setAnimation(set);
}