android.animation.ValueAnimator#getCurrentPlayTime ( )源码实例Demo

下面列出了android.animation.ValueAnimator#getCurrentPlayTime ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: PhotoMovie   文件: MovieTimer.java
@Override
public void onAnimationUpdate(ValueAnimator animation) {
    if (mPaused || !animation.isRunning()) {
        return;
    }

    long curTime = animation.getCurrentPlayTime();

    if (curTime >= mPhotoMovie.getDuration()) {
        mAnimator.removeUpdateListener(this);
        mAnimator.removeListener(this);
        mAnimator.end();
        if (mMovieListener != null) {
            mMovieListener.onMovieEnd();
        }
        mAnimator.addUpdateListener(this);
        mAnimator.addListener(this);
        if(mLoop){
            mAnimator.start();
        }
    }else{
        if (mMovieListener != null) {
            mMovieListener.onMovieUpdate((int) curTime);
        }
    }
}
 
源代码2 项目: AndroidStudyDemo   文件: ViewAnim.java
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
	
	if (valueAnimator.getCurrentPlayTime() <= valueAnimator.getDuration()) {
		float fraction = valueAnimator.getAnimatedFraction();// 动画进度
		
		float scaleXDuration = mFinalBounds.width() - mStartBounds.width();
		float scaleYDuration = mFinalBounds.height() - mStartBounds.height();
		mView.getLayoutParams().width = (int)(mStartBounds.width() + (scaleXDuration * fraction));
		mView.getLayoutParams().height = (int)(mStartBounds.height() + (scaleYDuration * fraction));
		
		if (mListener != null) {
			mListener.onViewAnimationUpdate(mView, valueAnimator, fraction);
		}
	}
	mView.requestLayout();
}
 
源代码3 项目: nono-android   文件: ViewAnim.java
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
	
	if (valueAnimator.getCurrentPlayTime() <= valueAnimator.getDuration()) {
		float fraction = valueAnimator.getAnimatedFraction();// 动画进度
		
		float scaleXDuration = mFinalBounds.width() - mStartBounds.width();
		float scaleYDuration = mFinalBounds.height() - mStartBounds.height();
		mView.getLayoutParams().width = (int)(mStartBounds.width() + (scaleXDuration * fraction));
		mView.getLayoutParams().height = (int)(mStartBounds.height() + (scaleYDuration * fraction));
		
		if (mListener != null) {
			mListener.onViewAnimationUpdate(mView, valueAnimator, fraction);
		}
	}
	mView.requestLayout();
}
 
源代码4 项目: ActivityOptionsICS   文件: ViewAnim.java
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
	
	if (valueAnimator.getCurrentPlayTime() <= valueAnimator.getDuration()) {
		float fraction = valueAnimator.getAnimatedFraction();// 动画进度
		
		float scaleXDuration = mFinalBounds.width() - mStartBounds.width();
		float scaleYDuration = mFinalBounds.height() - mStartBounds.height();
		mView.getLayoutParams().width = (int)(mStartBounds.width() + (scaleXDuration * fraction));
		mView.getLayoutParams().height = (int)(mStartBounds.height() + (scaleYDuration * fraction));
		
		if (mListener != null) {
			mListener.onViewAnimationUpdate(mView, valueAnimator, fraction);
		}
	}
	mView.requestLayout();
}
 
源代码5 项目: SimplifyReader   文件: CircularProgressBarUtils.java
static float getAnimatedFraction(ValueAnimator animator) {
  float fraction = animator.getDuration() > 0 ? ((float) animator.getCurrentPlayTime()) / animator.getDuration() : 0f;

  fraction = min(fraction, 1f);
  fraction = animator.getInterpolator().getInterpolation(fraction);
  return fraction;
}
 
源代码6 项目: Lay-s   文件: CircularProgressBarUtils.java
static float getAnimatedFraction(ValueAnimator animator) {
  float fraction = animator.getDuration() > 0 ? ((float) animator.getCurrentPlayTime()) / animator.getDuration() : 0f;

  fraction = min(fraction, 1f);
  fraction = animator.getInterpolator().getInterpolation(fraction);
  return fraction;
}
 
源代码7 项目: UltimateAndroid   文件: IconReleasePainter.java
@Override public void onAnimationUpdate(ValueAnimator animation) {
  iconYPosition = ((int) animation.getAnimatedValue() - iconMargin);

  if (animation.getCurrentPlayTime() > animation.getDuration() / 2
      && !alphaEnterTrigger
      && actualState.equals(MaterialAnimatedSwitchState.RELEASE)) {
    exitAlphaAnimator.start();
    alphaEnterTrigger = true;
  }
}
 
源代码8 项目: dingo   文件: FloatingView.java
/**
 * Update animation initialization flag
 *
 * @param animation {@link ValueAnimator}
 */
private void updateInitAnimation(ValueAnimator animation) {
    if (mAnimateInitialMove && animation.getDuration() <= animation.getCurrentPlayTime()) {
        mIsInitialAnimationRunning = false;
    }
}
 
源代码9 项目: LaunchEnr   文件: FirstFrameAnimatorHelper.java
public void onAnimationUpdate(final ValueAnimator animation) {
    final long currentTime = System.currentTimeMillis();
    if (mStartTime == -1) {
        mStartFrame = sGlobalFrameCounter;
        mStartTime = currentTime;
    }

    final long currentPlayTime = animation.getCurrentPlayTime();
    boolean isFinalFrame = Float.compare(1f, animation.getAnimatedFraction()) == 0;

    if (!mHandlingOnAnimationUpdate &&
        sVisible &&
        // If the current play time exceeds the duration, or the animated fraction is 1,
        // the animation will get finished, even if we call setCurrentPlayTime -- therefore
        // don't adjust the animation in that case
        currentPlayTime < animation.getDuration() && !isFinalFrame) {
        mHandlingOnAnimationUpdate = true;
        long frameNum = sGlobalFrameCounter - mStartFrame;
        // If we haven't drawn our first frame, reset the time to t = 0
        // (give up after MAX_DELAY ms of waiting though - might happen, for example, if we
        // are no longer in the foreground and no frames are being rendered ever)
        if (frameNum == 0 && currentTime < mStartTime + MAX_DELAY && currentPlayTime > 0) {
            // The first frame on animations doesn't always trigger an invalidate...
            // force an invalidate here to make sure the animation continues to advance
            mTarget.getRootView().invalidate();
            animation.setCurrentPlayTime(0);
        // For the second frame, if the first frame took more than 16ms,
        // adjust the start time and pretend it took only 16ms anyway. This
        // prevents a large jump in the animation due to an expensive first frame
        } else if (frameNum == 1 && currentTime < mStartTime + MAX_DELAY &&
                   !mAdjustedSecondFrameTime &&
                   currentTime > mStartTime + IDEAL_FRAME_DURATION &&
                   currentPlayTime > IDEAL_FRAME_DURATION) {
            animation.setCurrentPlayTime(IDEAL_FRAME_DURATION);
            mAdjustedSecondFrameTime = true;
        } else {
            if (frameNum > 1) {
                mTarget.post(new Runnable() {
                        public void run() {
                            animation.removeUpdateListener(FirstFrameAnimatorHelper.this);
                        }
                    });
            }
        }
        mHandlingOnAnimationUpdate = false;
    }
}
 
源代码10 项目: Trebuchet   文件: FirstFrameAnimatorHelper.java
public void onAnimationUpdate(final ValueAnimator animation) {
    final long currentTime = System.currentTimeMillis();
    if (mStartTime == -1) {
        mStartFrame = sGlobalFrameCounter;
        mStartTime = currentTime;
    }

    final long currentPlayTime = animation.getCurrentPlayTime();
    boolean isFinalFrame = Float.compare(1f, animation.getAnimatedFraction()) == 0;

    if (!mHandlingOnAnimationUpdate &&
        sVisible &&
        // If the current play time exceeds the duration, or the animated fraction is 1,
        // the animation will get finished, even if we call setCurrentPlayTime -- therefore
        // don't adjust the animation in that case
        currentPlayTime < animation.getDuration() && !isFinalFrame) {
        mHandlingOnAnimationUpdate = true;
        long frameNum = sGlobalFrameCounter - mStartFrame;
        // If we haven't drawn our first frame, reset the time to t = 0
        // (give up after MAX_DELAY ms of waiting though - might happen, for example, if we
        // are no longer in the foreground and no frames are being rendered ever)
        if (frameNum == 0 && currentTime < mStartTime + MAX_DELAY && currentPlayTime > 0) {
            // The first frame on animations doesn't always trigger an invalidate...
            // force an invalidate here to make sure the animation continues to advance
            mTarget.getRootView().invalidate();
            animation.setCurrentPlayTime(0);
        // For the second frame, if the first frame took more than 16ms,
        // adjust the start time and pretend it took only 16ms anyway. This
        // prevents a large jump in the animation due to an expensive first frame
        } else if (frameNum == 1 && currentTime < mStartTime + MAX_DELAY &&
                   !mAdjustedSecondFrameTime &&
                   currentTime > mStartTime + IDEAL_FRAME_DURATION &&
                   currentPlayTime > IDEAL_FRAME_DURATION) {
            animation.setCurrentPlayTime(IDEAL_FRAME_DURATION);
            mAdjustedSecondFrameTime = true;
        } else {
            if (frameNum > 1) {
                mTarget.post(new Runnable() {
                        public void run() {
                            animation.removeUpdateListener(FirstFrameAnimatorHelper.this);
                        }
                    });
            }
            if (DEBUG) print(animation);
        }
        mHandlingOnAnimationUpdate = false;
    } else {
        if (DEBUG) print(animation);
    }
}
 
源代码11 项目: Trebuchet   文件: FirstFrameAnimatorHelper.java
public void print(ValueAnimator animation) {
    float flatFraction = animation.getCurrentPlayTime() / (float) animation.getDuration();
    Log.d("FirstFrameAnimatorHelper", sGlobalFrameCounter +
          "(" + (sGlobalFrameCounter - mStartFrame) + ") " + mTarget + " dirty? " +
          mTarget.isDirty() + " " + flatFraction + " " + this + " " + animation);
}
 
源代码12 项目: TurboLauncher   文件: FirstFrameAnimatorHelper.java
public void onAnimationUpdate(final ValueAnimator animation) {
    final long currentTime = System.currentTimeMillis();
    if (mStartTime == -1) {
        mStartFrame = sGlobalFrameCounter;
        mStartTime = currentTime;
    }

    final long currentPlayTime = animation.getCurrentPlayTime();
    if (!mHandlingOnAnimationUpdate &&
        sVisible &&
        // If the current play time exceeds the duration, the animation
        // will get finished, even if we call setCurrentPlayTime -- therefore
        // don't adjust the animation in that case
        currentPlayTime < animation.getDuration()) {
        mHandlingOnAnimationUpdate = true;
        long frameNum = sGlobalFrameCounter - mStartFrame;
        // If we haven't drawn our first frame, reset the time to t = 0
        // (give up after MAX_DELAY ms of waiting though - might happen, for example, if we
        // are no longer in the foreground and no frames are being rendered ever)
        if (frameNum == 0 && currentTime < mStartTime + MAX_DELAY && currentPlayTime > 0) {
            // The first frame on animations doesn't always trigger an invalidate...
            // force an invalidate here to make sure the animation continues to advance
            mTarget.getRootView().invalidate();
            animation.setCurrentPlayTime(0);
        // For the second frame, if the first frame took more than 16ms,
        // adjust the start time and pretend it took only 16ms anyway. This
        // prevents a large jump in the animation due to an expensive first frame
        } else if (frameNum == 1 && currentTime < mStartTime + MAX_DELAY &&
                   !mAdjustedSecondFrameTime &&
                   currentTime > mStartTime + IDEAL_FRAME_DURATION &&
                   currentPlayTime > IDEAL_FRAME_DURATION) {
            animation.setCurrentPlayTime(IDEAL_FRAME_DURATION);
            mAdjustedSecondFrameTime = true;
        } else {
            if (frameNum > 1) {
                mTarget.post(new Runnable() {
                        public void run() {
                            animation.removeUpdateListener(FirstFrameAnimatorHelper.this);
                        }
                    });
            }
            if (DEBUG) print(animation);
        }
        mHandlingOnAnimationUpdate = false;
    } else {
        if (DEBUG) print(animation);
    }
}
 
源代码13 项目: TurboLauncher   文件: FirstFrameAnimatorHelper.java
public void print(ValueAnimator animation) {
    float flatFraction = animation.getCurrentPlayTime() / (float) animation.getDuration();
    Log.d("FirstFrameAnimatorHelper", sGlobalFrameCounter +
          "(" + (sGlobalFrameCounter - mStartFrame) + ") " + mTarget + " dirty? " +
          mTarget.isDirty() + " " + flatFraction + " " + this + " " + animation);
}
 
源代码14 项目: FloatingView   文件: FloatingView.java
/**
 * Update animation initialization flag
 *
 * @param animation {@link ValueAnimator}
 */
private void updateInitAnimation(ValueAnimator animation) {
    if (mAnimateInitialMove && animation.getDuration() <= animation.getCurrentPlayTime()) {
        mIsInitialAnimationRunning = false;
    }
}
 
源代码15 项目: LB-Launcher   文件: FirstFrameAnimatorHelper.java
public void onAnimationUpdate(final ValueAnimator animation) {
    final long currentTime = System.currentTimeMillis();
    if (mStartTime == -1) {
        mStartFrame = sGlobalFrameCounter;
        mStartTime = currentTime;
    }

    final long currentPlayTime = animation.getCurrentPlayTime();
    boolean isFinalFrame = Float.compare(1f, animation.getAnimatedFraction()) == 0;

    if (!mHandlingOnAnimationUpdate &&
        sVisible &&
        // If the current play time exceeds the duration, or the animated fraction is 1,
        // the animation will get finished, even if we call setCurrentPlayTime -- therefore
        // don't adjust the animation in that case
        currentPlayTime < animation.getDuration() && !isFinalFrame) {
        mHandlingOnAnimationUpdate = true;
        long frameNum = sGlobalFrameCounter - mStartFrame;
        // If we haven't drawn our first frame, reset the time to t = 0
        // (give up after MAX_DELAY ms of waiting though - might happen, for example, if we
        // are no longer in the foreground and no frames are being rendered ever)
        if (frameNum == 0 && currentTime < mStartTime + MAX_DELAY && currentPlayTime > 0) {
            // The first frame on animations doesn't always trigger an invalidate...
            // force an invalidate here to make sure the animation continues to advance
            mTarget.getRootView().invalidate();
            animation.setCurrentPlayTime(0);
        // For the second frame, if the first frame took more than 16ms,
        // adjust the start time and pretend it took only 16ms anyway. This
        // prevents a large jump in the animation due to an expensive first frame
        } else if (frameNum == 1 && currentTime < mStartTime + MAX_DELAY &&
                   !mAdjustedSecondFrameTime &&
                   currentTime > mStartTime + IDEAL_FRAME_DURATION &&
                   currentPlayTime > IDEAL_FRAME_DURATION) {
            animation.setCurrentPlayTime(IDEAL_FRAME_DURATION);
            mAdjustedSecondFrameTime = true;
        } else {
            if (frameNum > 1) {
                mTarget.post(new Runnable() {
                        public void run() {
                            animation.removeUpdateListener(FirstFrameAnimatorHelper.this);
                        }
                    });
            }
            if (DEBUG) print(animation);
        }
        mHandlingOnAnimationUpdate = false;
    } else {
        if (DEBUG) print(animation);
    }
}
 
源代码16 项目: LB-Launcher   文件: FirstFrameAnimatorHelper.java
public void print(ValueAnimator animation) {
    float flatFraction = animation.getCurrentPlayTime() / (float) animation.getDuration();
    Log.d("FirstFrameAnimatorHelper", sGlobalFrameCounter +
          "(" + (sGlobalFrameCounter - mStartFrame) + ") " + mTarget + " dirty? " +
          mTarget.isDirty() + " " + flatFraction + " " + this + " " + animation);
}