getcurrenttime java,Java ValueAnimator.getCurrentPlayTime方法代码示例

import android.animation.ValueAnimator; //导入方法依赖的package包/类

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);

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值