Methods Summary |
---|
private void | applyInterpolator()
if (mInterpolator == null) return;
long ni;
if (isNativeInterpolator(mInterpolator)) {
ni = ((NativeInterpolatorFactory)mInterpolator).createNativeInterpolator();
} else {
long duration = nGetDuration(mNativePtr.get());
ni = FallbackLUTInterpolator.createNativeInterpolator(mInterpolator, duration);
}
nSetInterpolator(mNativePtr.get(), ni);
|
private static void | callOnFinished(android.view.RenderNodeAnimator animator)
animator.onFinished();
|
public void | cancel()
if (mState != STATE_PREPARE && mState != STATE_FINISHED) {
if (mState == STATE_DELAYED) {
getHelper().removeDelayedAnimation(this);
moveToRunningState();
}
final ArrayList<AnimatorListener> listeners = cloneListeners();
final int numListeners = listeners == null ? 0 : listeners.size();
for (int i = 0; i < numListeners; i++) {
listeners.get(i).onAnimationCancel(this);
}
end();
}
|
private void | checkMutable()
if (mState != STATE_PREPARE) {
throw new IllegalStateException("Animator has already started, cannot change it now!");
}
if (mNativePtr == null) {
throw new IllegalStateException("Animator's target has been destroyed "
+ "(trying to modify an animation after activity destroy?)");
}
|
public android.animation.Animator | clone()
throw new IllegalStateException("Cannot clone this animator");
|
private java.util.ArrayList | cloneListeners()
ArrayList<AnimatorListener> listeners = getListeners();
if (listeners != null) {
listeners = (ArrayList<AnimatorListener>) listeners.clone();
}
return listeners;
|
private void | doStart()
// Alpha is a special snowflake that has the canonical value stored
// in mTransformationInfo instead of in RenderNode, so we need to update
// it with the final value here.
if (mRenderProperty == RenderNodeAnimator.ALPHA) {
// Don't need null check because ViewPropertyAnimator's
// ctor calls ensureTransformationInfo()
mViewTarget.mTransformationInfo.mAlpha = mFinalValue;
}
moveToRunningState();
if (mViewTarget != null) {
// Kick off a frame to start the process
mViewTarget.invalidateViewProperty(true, false);
}
|
public void | end()
if (mState != STATE_FINISHED) {
if (mState < STATE_RUNNING) {
getHelper().removeDelayedAnimation(this);
doStart();
}
if (mNativePtr != null) {
nEnd(mNativePtr.get());
if (mViewTarget != null) {
// Kick off a frame to flush the state change
mViewTarget.invalidateViewProperty(true, false);
}
} else {
// It's already dead, jump to onFinish
onFinished();
}
}
|
public long | getDuration()
return mUnscaledDuration;
|
private static android.view.RenderNodeAnimator$DelayedAnimationHelper | getHelper()
DelayedAnimationHelper helper = sAnimationHelper.get();
if (helper == null) {
helper = new DelayedAnimationHelper();
sAnimationHelper.set(helper);
}
return helper;
|
public android.animation.TimeInterpolator | getInterpolator()
return mInterpolator;
|
long | getNativeAnimator()
return mNativePtr.get();
|
public long | getStartDelay()
return mUnscaledStartDelay;
|
private void | init(long ptr)
mNativePtr = new VirtualRefBasePtr(ptr);
|
static boolean | isNativeInterpolator(android.animation.TimeInterpolator interpolator)
return interpolator.getClass().isAnnotationPresent(HasNativeInterpolator.class);
|
public boolean | isRunning()
return mState == STATE_DELAYED || mState == STATE_RUNNING;
|
public boolean | isStarted()
return mState != STATE_PREPARE;
|
public static int | mapViewPropertyToRenderProperty(int viewProperty)
return sViewPropertyAnimatorMap.get(viewProperty);
|
private void | moveToRunningState()
mState = STATE_RUNNING;
if (mNativePtr != null) {
nStart(mNativePtr.get());
}
notifyStartListeners();
|
private static native long | nCreateAnimator(int property, float finalValue)
|
private static native long | nCreateCanvasPropertyFloatAnimator(long canvasProperty, float finalValue)
|
private static native long | nCreateCanvasPropertyPaintAnimator(long canvasProperty, int paintField, float finalValue)
|
private static native long | nCreateRevealAnimator(int x, int y, float startRadius, float endRadius)
|
private static native void | nEnd(long animPtr)
|
private static native long | nGetDuration(long nativePtr)
|
private static native void | nSetAllowRunningAsync(long animPtr, boolean mayRunAsync)
|
private static native void | nSetDuration(long nativePtr, long duration)
|
private static native void | nSetInterpolator(long animPtr, long interpolatorPtr)
|
private static native void | nSetListener(long animPtr, android.view.RenderNodeAnimator listener)
|
private static native void | nSetStartDelay(long nativePtr, long startDelay)
|
private static native void | nSetStartValue(long nativePtr, float startValue)
|
private static native void | nStart(long animPtr)
|
private void | notifyStartListeners()
final ArrayList<AnimatorListener> listeners = cloneListeners();
final int numListeners = listeners == null ? 0 : listeners.size();
for (int i = 0; i < numListeners; i++) {
listeners.get(i).onAnimationStart(this);
}
|
protected void | onFinished()
if (mState == STATE_PREPARE) {
// Unlikely but possible, the native side has been destroyed
// before we have started.
releaseNativePtr();
return;
}
if (mState == STATE_DELAYED) {
getHelper().removeDelayedAnimation(this);
notifyStartListeners();
}
mState = STATE_FINISHED;
final ArrayList<AnimatorListener> listeners = cloneListeners();
final int numListeners = listeners == null ? 0 : listeners.size();
for (int i = 0; i < numListeners; i++) {
listeners.get(i).onAnimationEnd(this);
}
// Release the native object, as it has a global reference to us. This
// breaks the cyclic reference chain, and allows this object to be
// GC'd
releaseNativePtr();
|
public void | pause()
throw new UnsupportedOperationException();
|
private boolean | processDelayed(long frameTimeMs)
if (mStartTime == 0) {
mStartTime = frameTimeMs;
} else if ((frameTimeMs - mStartTime) >= mStartDelay) {
doStart();
return true;
}
return false;
|
private void | releaseNativePtr()
if (mNativePtr != null) {
mNativePtr.release();
mNativePtr = null;
}
|
public void | resume()
throw new UnsupportedOperationException();
|
public void | setAllowRunningAsynchronously(boolean mayRunAsync)
checkMutable();
nSetAllowRunningAsync(mNativePtr.get(), mayRunAsync);
|
public android.view.RenderNodeAnimator | setDuration(long duration)
checkMutable();
if (duration < 0) {
throw new IllegalArgumentException("duration must be positive; " + duration);
}
mUnscaledDuration = duration;
nSetDuration(mNativePtr.get(), (long) (duration * ValueAnimator.getDurationScale()));
return this;
|
public void | setInterpolator(android.animation.TimeInterpolator interpolator)
checkMutable();
mInterpolator = interpolator;
|
public void | setStartDelay(long startDelay)
checkMutable();
if (startDelay < 0) {
throw new IllegalArgumentException("startDelay must be positive; " + startDelay);
}
mUnscaledStartDelay = startDelay;
mStartDelay = (long) (ValueAnimator.getDurationScale() * startDelay);
|
public void | setStartValue(float startValue)
checkMutable();
nSetStartValue(mNativePtr.get(), startValue);
|
public void | setTarget(View view)
mViewTarget = view;
setTarget(mViewTarget.mRenderNode);
|
public void | setTarget(android.graphics.Canvas canvas)
if (!(canvas instanceof GLES20RecordingCanvas)) {
throw new IllegalArgumentException("Not a GLES20RecordingCanvas");
}
final GLES20RecordingCanvas recordingCanvas = (GLES20RecordingCanvas) canvas;
setTarget(recordingCanvas.mNode);
|
private void | setTarget(RenderNode node)
checkMutable();
if (mTarget != null) {
throw new IllegalStateException("Target already set!");
}
nSetListener(mNativePtr.get(), this);
mTarget = node;
mTarget.addAnimator(this);
|
public void | start()
if (mTarget == null) {
throw new IllegalStateException("Missing target!");
}
if (mState != STATE_PREPARE) {
throw new IllegalStateException("Already started!");
}
mState = STATE_DELAYED;
applyInterpolator();
if (mNativePtr == null) {
// It's dead, immediately cancel
cancel();
} else if (mStartDelay <= 0 || !mUiThreadHandlesDelay) {
nSetStartDelay(mNativePtr.get(), mStartDelay);
doStart();
} else {
getHelper().addDelayedAnimation(this);
}
|