Beispiel #1
0
 @Override
 public ValueAnimator clone() {
   final ValueAnimator anim = (ValueAnimator) super.clone();
   if (mUpdateListeners != null) {
     ArrayList<AnimatorUpdateListener> oldListeners = mUpdateListeners;
     anim.mUpdateListeners = new ArrayList<AnimatorUpdateListener>();
     int numListeners = oldListeners.size();
     for (AnimatorUpdateListener oldListener : oldListeners) {
       anim.mUpdateListeners.add(oldListener);
     }
   }
   anim.mSeekTime = -1;
   anim.mPlayingBackwards = false;
   anim.mCurrentIteration = 0;
   anim.mInitialized = false;
   anim.mPlayingState = STOPPED;
   anim.mStartedDelay = false;
   PropertyValuesHolder[] oldValues = mValues;
   if (oldValues != null) {
     int numValues = oldValues.length;
     anim.mValues = new PropertyValuesHolder[numValues];
     anim.mValuesMap = new HashMap<String, PropertyValuesHolder>(numValues);
     for (int i = 0; i < numValues; ++i) {
       PropertyValuesHolder newValuesHolder = oldValues[i].clone();
       anim.mValues[i] = newValuesHolder;
       anim.mValuesMap.put(newValuesHolder.getPropertyName(), newValuesHolder);
     }
   }
   return anim;
 }
Beispiel #2
0
 public static ValueAnimator ofObject(TypeEvaluator evaluator, Object... values) {
   ValueAnimator anim = new ValueAnimator();
   anim.setObjectValues(values);
   anim.setEvaluator(evaluator);
   return anim;
 }
Beispiel #3
0
 public static ValueAnimator ofPropertyValuesHolder(PropertyValuesHolder... values) {
   ValueAnimator anim = new ValueAnimator();
   anim.setValues(values);
   return anim;
 }
Beispiel #4
0
 public static ValueAnimator ofFloat(float... values) {
   ValueAnimator anim = new ValueAnimator();
   anim.setFloatValues(values);
   return anim;
 }
Beispiel #5
0
 public static ValueAnimator ofInt(int... values) {
   ValueAnimator anim = new ValueAnimator();
   anim.setIntValues(values);
   return anim;
 }
Beispiel #6
0
    private void doAnimationFrame(long frameTime) {
      while (mPendingAnimations.size() > 0) {
        ArrayList<ValueAnimator> pendingCopy =
            (ArrayList<ValueAnimator>) mPendingAnimations.clone();
        mPendingAnimations.clear();
        int count = pendingCopy.size();
        for (ValueAnimator anim : pendingCopy) {
          if (anim.mStartDelay == 0) {
            anim.startAnimation(this);
          } else {
            mDelayedAnims.add(anim);
          }
        }
      }

      int numDelayedAnims = mDelayedAnims.size();
      for (ValueAnimator anim : mDelayedAnims) {
        if (anim.delayedAnimationFrame(frameTime)) {
          mReadyAnims.add(anim);
        }
      }
      int numReadyAnims = mReadyAnims.size();
      if (numReadyAnims > 0) {
        for (ValueAnimator anim : mReadyAnims) {
          anim.startAnimation(this);
          anim.mRunning = true;
          mDelayedAnims.remove(anim);
        }
        mReadyAnims.clear();
      }

      int numAnims = mAnimations.size();
      for (ValueAnimator mAnimation : mAnimations) {
        mTmpAnimations.add(mAnimation);
      }
      for (int i = 0; i < numAnims; ++i) {
        ValueAnimator anim = mTmpAnimations.get(i);
        if (mAnimations.contains(anim) && anim.doAnimationFrame(frameTime)) {
          mEndingAnims.add(anim);
        }
      }
      mTmpAnimations.clear();
      if (mEndingAnims.size() > 0) {
        for (ValueAnimator mEndingAnim : mEndingAnims) {
          mEndingAnim.endAnimation(this);
        }
        mEndingAnims.clear();
      }

      if (!mAnimations.isEmpty() || !mDelayedAnims.isEmpty()) {
        scheduleAnimation();
      }
    }