Java Code Examples for android.view.animation.Animation#getClass()

The following examples show how to use android.view.animation.Animation#getClass() . 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: AnimationHelpers.java    From ripple with GNU General Public License v3.0 5 votes vote down vote up
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
            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);
}
 
Example 2
Source File: UIHelpers.java    From CameraV with GNU General Public License v3.0 4 votes vote down vote up
public static void addAnimation(View view, Animation animation, boolean first)
{
	Animation previousAnimation = view.getAnimation();
	if (previousAnimation == null || previousAnimation.getClass() == animation.getClass())
	{
		view.startAnimation(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);
}