Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright (C) 2010 The Android Open Source Project
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *      http://www.apache.org/licenses/LICENSE-2.0
   *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 
 package com.actionbarsherlock.internal.nineoldandroids.animation;
 
 
This is the superclass for classes which provide basic support for animations which can be started, ended, and have AnimatorListeners added to them.
 
 public abstract class Animator implements Cloneable {


    
The set of listeners to be sent events through the life of an animation.
 
     ArrayList<AnimatorListenermListeners = null;

    
Starts this animation. If the animation has a nonzero startDelay, the animation will start running after that delay elapses. A non-delayed animation will have its initial value(s) set immediately, followed by calls to Animator.AnimatorListener.onAnimationStart(com.actionbarsherlock.internal.nineoldandroids.animation.Animator) for any listeners of this animator.

The animation started by calling this method will be run on the thread that called this method. This thread should have a Looper on it (a runtime exception will be thrown if this is not the case). Also, if the animation will animate properties of objects in the view hierarchy, then the calling thread should be the UI thread for that view hierarchy.

 
     public void start() {
     }

    
Cancels the animation. Unlike end(), cancel() causes the animation to stop in its tracks, sending an android.animation.Animator.AnimatorListener.onAnimationCancel(android.animation.Animator) to its listeners, followed by an android.animation.Animator.AnimatorListener.onAnimationEnd(android.animation.Animator) message.

This method must be called on the thread that is running the animation.

 
     public void cancel() {
     }

    
Ends the animation. This causes the animation to assign the end value of the property being animated, then calling the android.animation.Animator.AnimatorListener.onAnimationEnd(android.animation.Animator) method on its listeners.

This method must be called on the thread that is running the animation.

 
     public void end() {
     }

    
The amount of time, in milliseconds, to delay starting the animation after start() is called.

Returns:
the number of milliseconds to delay running the animation
 
     public abstract long getStartDelay();

    
The amount of time, in milliseconds, to delay starting the animation after start() is called.

Parameters:
startDelay The amount of the delay, in milliseconds
 
     public abstract void setStartDelay(long startDelay);


    
Sets the length of the animation.

Parameters:
duration The length of the animation, in milliseconds.
 
     public abstract Animator setDuration(long duration);

    
Gets the length of the animation.

Returns:
The length of the animation, in milliseconds.
    public abstract long getDuration();

    
The time interpolator used in calculating the elapsed fraction of this animation. The interpolator determines whether the animation runs with linear or non-linear motion, such as acceleration and deceleration. The default value is android.view.animation.AccelerateDecelerateInterpolator

Parameters:
value the interpolator to be used by this animation
    public abstract void setInterpolator(/*Time*/Interpolator value);

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

Returns:
Whether the Animator is running.
    public abstract boolean isRunning();

    
Returns whether this Animator has been started and not yet ended. This state is a superset of the state of isRunning(), because an Animator with a nonzero startDelay will return true for isStarted() during the delay phase, whereas isRunning() will return true only after the delay phase is complete.

Returns:
Whether the Animator has been started and not yet ended.
    public boolean isStarted() {
        // Default method returns value for isRunning(). Subclasses should override to return a
        // real value.
        return isRunning();
    }

    
Adds a listener to the set of listeners that are sent events through the life of an animation, such as start, repeat, and end.

Parameters:
listener the listener to be added to the current set of listeners for this animation.
    public void addListener(AnimatorListener listener) {
        if ( == null) {
             = new ArrayList<AnimatorListener>();
        }
        .add(listener);
    }

    
Removes a listener from the set listening to this animation.

Parameters:
listener the listener to be removed from the current set of listeners for this animation.
    public void removeListener(AnimatorListener listener) {
        if ( == null) {
            return;
        }
        .remove(listener);
        if (.size() == 0) {
             = null;
        }
    }

    
Gets the set of android.animation.Animator.AnimatorListener objects that are currently listening for events on this Animator object.

Returns:
ArrayList<AnimatorListener> The set of listeners.
        return ;
    }

    
Removes all listeners from this object. This is equivalent to calling getListeners() followed by calling clear() on the returned list of listeners.
    public void removeAllListeners() {
        if ( != null) {
            .clear();
             = null;
        }
    }
    @Override
    public Animator clone() {
        try {
            final Animator anim = (Animatorsuper.clone();
            if ( != null) {
                ArrayList<AnimatorListeneroldListeners = ;
                anim.mListeners = new ArrayList<AnimatorListener>();
                int numListeners = oldListeners.size();
                for (int i = 0; i < numListeners; ++i) {
                    anim.mListeners.add(oldListeners.get(i));
                }
            }
            return anim;
        } catch (CloneNotSupportedException e) {
           throw new AssertionError();
        }
    }

    
This method tells the object to use appropriate information to extract starting values for the animation. For example, a AnimatorSet object will pass this call to its child objects to tell them to set up the values. A ObjectAnimator object will use the information it has about its target object and PropertyValuesHolder objects to get the start values for its properties. An ValueAnimator object will ignore the request since it does not have enough information (such as a target object) to gather these values.
    public void setupStartValues() {
    }

    
This method tells the object to use appropriate information to extract ending values for the animation. For example, a AnimatorSet object will pass this call to its child objects to tell them to set up the values. A ObjectAnimator object will use the information it has about its target object and PropertyValuesHolder objects to get the start values for its properties. An ValueAnimator object will ignore the request since it does not have enough information (such as a target object) to gather these values.
    public void setupEndValues() {
    }

    
Sets the target object whose property will be animated by this animation. Not all subclasses operate on target objects (for example, ValueAnimator, but this method is on the superclass for the convenience of dealing generically with those subclasses that do handle targets.

Parameters:
target The object being animated
    public void setTarget(Object target) {
    }

    

An animation listener receives notifications from an animation. Notifications indicate animation related events, such as the end or the repetition of the animation.

    public static interface AnimatorListener {
        

Notifies the start of the animation.

Parameters:
animation The started animation.
        void onAnimationStart(Animator animation);

        

Notifies the end of the animation. This callback is not invoked for animations with repeat count set to INFINITE.

Parameters:
animation The animation which reached its end.
        void onAnimationEnd(Animator animation);

        

Notifies the cancellation of the animation. This callback is not invoked for animations with repeat count set to INFINITE.

Parameters:
animation The animation which was canceled.
        void onAnimationCancel(Animator animation);

        

Notifies the repetition of the animation.

Parameters:
animation The animation which was repeated.
        void onAnimationRepeat(Animator animation);
    }
New to GrepCode? Check out our FAQ X