FileDocCategorySizeDatePackage
ViewPropertyAnimatorRT.javaAPI DocAndroid 5.1 API4960Thu Mar 12 22:22:10 GMT 2015android.view

ViewPropertyAnimatorRT

public class ViewPropertyAnimatorRT extends Object
This is a RenderThread driven backend for ViewPropertyAnimator.

Fields Summary
private static final android.view.animation.Interpolator
sLinearInterpolator
private final View
mView
private RenderNodeAnimator[]
mAnimators
Constructors Summary
ViewPropertyAnimatorRT(View view)


      
        mView = view;
    
Methods Summary
private booleancanHandleAnimator(ViewPropertyAnimator parent)

        // TODO: Can we eliminate this entirely?
        // If RenderNode.animatorProperties() can be toggled to point at staging
        // instead then RNA can be used as the animators for software as well
        // as the updateListener fallback paths. If this can be toggled
        // at the top level somehow, combined with requiresUiRedraw, we could
        // ensure that RT does not self-animate, allowing for safe driving of
        // the animators from the UI thread using the same mechanisms
        // ViewPropertyAnimator does, just with everything sitting on a single
        // animator subsystem instead of multiple.

        if (parent.getUpdateListener() != null) {
            return false;
        }
        if (parent.getListener() != null) {
            // TODO support
            return false;
        }
        if (!mView.isHardwareAccelerated()) {
            // TODO handle this maybe?
            return false;
        }
        if (parent.hasActions()) {
            return false;
        }
        // Here goes nothing...
        return true;
    
public voidcancelAll()

        for (int i = 0; i < mAnimators.length; i++) {
            if (mAnimators[i] != null) {
                mAnimators[i].cancel();
                mAnimators[i] = null;
            }
        }
    
private voidcancelAnimators(java.util.ArrayList mPendingAnimations)

        int size = mPendingAnimations.size();
        for (int i = 0; i < size; i++) {
            NameValuesHolder holder = mPendingAnimations.get(i);
            int property = RenderNodeAnimator.mapViewPropertyToRenderProperty(holder.mNameConstant);
            if (mAnimators[property] != null) {
                mAnimators[property].cancel();
                mAnimators[property] = null;
            }
        }
    
private voiddoStartAnimation(ViewPropertyAnimator parent)

        int size = parent.mPendingAnimations.size();

        long startDelay = parent.getStartDelay();
        long duration = parent.getDuration();
        TimeInterpolator interpolator = parent.getInterpolator();
        if (interpolator == null) {
            // Documented to be LinearInterpolator in ValueAnimator.setInterpolator
            interpolator = sLinearInterpolator;
        }
        if (!RenderNodeAnimator.isNativeInterpolator(interpolator)) {
            interpolator = new FallbackLUTInterpolator(interpolator, duration);
        }
        for (int i = 0; i < size; i++) {
            NameValuesHolder holder = parent.mPendingAnimations.get(i);
            int property = RenderNodeAnimator.mapViewPropertyToRenderProperty(holder.mNameConstant);

            final float finalValue = holder.mFromValue + holder.mDeltaValue;
            RenderNodeAnimator animator = new RenderNodeAnimator(property, finalValue);
            animator.setStartDelay(startDelay);
            animator.setDuration(duration);
            animator.setInterpolator(interpolator);
            animator.setTarget(mView);
            animator.start();

            mAnimators[property] = animator;
        }

        parent.mPendingAnimations.clear();
    
public booleanstartAnimation(ViewPropertyAnimator parent)

return
true if ViewPropertyAnimatorRT handled the animation, false if ViewPropertyAnimator needs to handle it

        cancelAnimators(parent.mPendingAnimations);
        if (!canHandleAnimator(parent)) {
            return false;
        }
        doStartAnimation(parent);
        return true;