Ejemplo n.º 1
0
 private void start() {
   startTime = animation.getStartTime();
   startOffset = animation.getStartOffset();
   Choreographer choreographer = ShadowChoreographer.getInstance();
   if (animationRunner != null) {
     choreographer.removeCallbacks(Choreographer.CALLBACK_ANIMATION, animationRunner, null);
   }
   animationRunner = this;
   int startDelay;
   if (startTime == Animation.START_ON_FIRST_FRAME) {
     startDelay = (int) startOffset;
   } else {
     startDelay = (int) ((startTime + startOffset) - SystemClock.uptimeMillis());
   }
   choreographer.postCallbackDelayed(Choreographer.CALLBACK_ANIMATION, this, null, startDelay);
 }
Ejemplo n.º 2
0
 @Override
 public void run() {
   // Abort if start time has been messed with, as this simulation is only designed to handle
   // standard situations.
   if ((animation.getStartTime() == startTime && animation.getStartOffset() == startOffset)
       && animation.getTransformation(
           startTime == Animation.START_ON_FIRST_FRAME
               ? SystemClock.uptimeMillis()
               : (startTime + startOffset + elapsedTime),
           new Transformation())
       &&
       // We can't handle infinitely repeating animations in the current scheduling model,
       // so abort after one iteration.
       !(animation.getRepeatCount() == Animation.INFINITE
           && elapsedTime >= animation.getDuration())) {
     // Update startTime if it had a value of Animation.START_ON_FIRST_FRAME
     startTime = animation.getStartTime();
     elapsedTime += ShadowChoreographer.getFrameInterval() / TimeUtils.NANOS_PER_MS;
     ShadowChoreographer.getInstance()
         .postCallback(Choreographer.CALLBACK_ANIMATION, this, null);
   } else {
     animationRunner = null;
   }
 }