本文整理汇总了Java中android.animation.TimeAnimator类的典型用法代码示例。如果您正苦于以下问题:Java TimeAnimator类的具体用法?Java TimeAnimator怎么用?Java TimeAnimator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TimeAnimator类属于android.animation包,在下文中一共展示了TimeAnimator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onTimeUpdate
import android.animation.TimeAnimator; //导入依赖的package包/类
public void onTimeUpdate(TimeAnimator timeAnimator, long totalTime, long deltaTime) {
if (!this.mStarted.booleanValue()) {
this.mStarted = Boolean.valueOf(true);
if (this.mAnimationListener != null) {
this.mAnimationListener.onAnimationStart(null);
}
}
if (timeAnimator.isRunning()) {
if (isReallyClose().booleanValue()) {
stepFast();
} else {
step();
}
if (isFinished().booleanValue() && this.mAnimationListener != null) {
this.mAnimationListener.onAnimationEnd(null);
}
}
}
示例2: init
import android.animation.TimeAnimator; //导入依赖的package包/类
void init() {
this.handler = new Handler(Looper.getMainLooper());
this.mAnimationCallback = new TimeListener() {
public void onTimeUpdate(TimeAnimator animation, long totalTime, long deltaTime) {
PanelView.this.animationTick(deltaTime);
}
};
this.mStopAnimator = new Runnable() {
public void run() {
if (PanelView.this.mTimeAnimator != null && PanelView.this.mTimeAnimator.isStarted()) {
PanelView.this.LOG("Stop Animator : stopping", new Object[0]);
PanelView.this.mTimeAnimator.end();
PanelView.this.mRubberbanding = false;
PanelView.this.mClosing = false;
}
}
};
this.mTimeAnimator = new TimeAnimator();
this.mTimeAnimator.setTimeListener(this.mAnimationCallback);
}
示例3: onTimeUpdate
import android.animation.TimeAnimator; //导入依赖的package包/类
@Override
public void onTimeUpdate(TimeAnimator animation, long totalTimeMs, long deltaTimeMs) {
// Cap progress bar animation frame time so that it doesn't jump too much even when
// the animation is janky.
float progress = mAnimationLogic.updateProgress(mTargetProgress,
Math.min(deltaTimeMs, PROGRESS_FRAME_TIME_CAP_MS) * 0.001f, getWidth());
progress = Math.max(progress, 0);
ToolbarProgressBar.super.setProgress(progress);
if (mAnimatingView != null) {
int width = Math.abs(
getDrawable().getBounds().right - getDrawable().getBounds().left);
mAnimatingView.update(progress * width);
}
if (getProgress() == mTargetProgress) {
if (!mIsStarted) postOnAnimationDelayed(mHideRunnable, mHidingDelayMs);
mProgressAnimator.end();
return;
}
}
示例4: onTimeUpdate
import android.animation.TimeAnimator; //导入依赖的package包/类
@Override
public void onTimeUpdate(TimeAnimator animation, long totalTimeMs, long deltaTimeMs) {
// Cap progress bar animation frame time so that it doesn't jump too much even when
// the animation is janky.
ToolbarProgressBar.super.setProgress(mAnimationLogic.updateProgress(
mTargetProgress,
Math.max(deltaTimeMs, PROGRESS_FRAME_TIME_CAP_MS) * 0.001f,
getWidth()));
if (getProgress() == mTargetProgress) {
if (mTargetProgress == 1.0f && !mIsStarted) {
postOnAnimationDelayed(mHideRunnable, mHidingDelayMs);
}
mProgressAnimator.end();
return;
}
}
示例5: createJBRunnable
import android.animation.TimeAnimator; //导入依赖的package包/类
private Runnable createJBRunnable() {
// On JB, we rely on TimeAnimator to send events tied with vsync.
return new Runnable() {
@Override
public void run() {
mTimeAnimator = new TimeAnimator();
mTimeAnimator.setTimeListener(new TimeListener() {
@Override
public void onTimeUpdate(TimeAnimator animation, long totalTime,
long deltaTime) {
if (!sendEvent(mDownTime + totalTime)) {
mTimeAnimator.end();
}
}
});
mTimeAnimator.start();
}
};
}
示例6: createJBRunnable
import android.animation.TimeAnimator; //导入依赖的package包/类
private Runnable createJBRunnable() {
// On JB, we rely on TimeAnimator to send events tied with vsync.
return new Runnable() {
@Override
public void run() {
mTimeAnimator = new TimeAnimator();
mTimeAnimator.setTimeListener(new TimeListener() {
@Override
public void onTimeUpdate(TimeAnimator animation, long totalTime,
long deltaTime) {
if (!sendEvent(mStartTime + totalTime)) {
mTimeAnimator.end();
}
}
});
mTimeAnimator.start();
}
};
}
示例7: onTimeUpdate
import android.animation.TimeAnimator; //导入依赖的package包/类
@Override
public void onTimeUpdate(TimeAnimator animation, long totalTime, long deltaTime) {
if (mFrameTimesCount == mFrameTimesMs.length) {
mAnimator.end();
cleanUp();
Log.w(TAG, "Animation frame time recording reached the maximum number. It's either"
+ "the animation took too long or recording end is not called.");
return;
}
// deltaTime is 0 for the first frame.
if (deltaTime > 0) {
mFrameTimesMs[mFrameTimesCount++] = deltaTime;
}
}
示例8: onTimeUpdate
import android.animation.TimeAnimator; //导入依赖的package包/类
public void onTimeUpdate(TimeAnimator timeAnimator, long totalTime, long deltaTime) {
if (!timeAnimator.isRunning()) {
return;
}
if (((float) totalTime) > this.mDuration) {
timeAnimator.cancel();
if (this.mAnimationListener != null) {
this.mAnimationListener.onAnimationEnd(null);
return;
}
return;
}
step((float) totalTime);
}
示例9: AppMenuDragHelper
import android.animation.TimeAnimator; //导入依赖的package包/类
AppMenuDragHelper(Activity activity, AppMenu appMenu, int itemRowHeight) {
mActivity = activity;
mAppMenu = appMenu;
mItemRowHeight = itemRowHeight;
Resources res = mActivity.getResources();
mAutoScrollFullVelocity = res.getDimensionPixelSize(R.dimen.auto_scroll_full_velocity);
// If user is dragging and the popup ListView is too big to display at once,
// mDragScrolling animator scrolls mPopup.getListView() automatically depending on
// the user's touch position.
mDragScrolling.setTimeListener(new TimeAnimator.TimeListener() {
@Override
public void onTimeUpdate(TimeAnimator animation, long totalTime, long deltaTime) {
ListPopupWindow popup = mAppMenu.getPopup();
if (popup == null || popup.getListView() == null) return;
// We keep both mDragScrollOffset and mDragScrollOffsetRounded because
// the actual scrolling is by the rounded value but at the same time we also
// want to keep the precise scroll value in float.
mDragScrollOffset += (deltaTime * 0.001f) * mDragScrollingVelocity;
int diff = Math.round(mDragScrollOffset - mDragScrollOffsetRounded);
mDragScrollOffsetRounded += diff;
popup.getListView().smoothScrollBy(diff, 0);
// Force touch move event to highlight items correctly for the scrolled position.
if (!Float.isNaN(mLastTouchX) && !Float.isNaN(mLastTouchY)) {
menuItemAction(Math.round(mLastTouchX), Math.round(mLastTouchY),
ITEM_ACTION_HIGHLIGHT);
}
}
});
// We use medium timeout, the average of tap and long press timeouts. This is consistent
// with ListPopupWindow#ForwardingListener implementation.
mTapTimeout =
(ViewConfiguration.getTapTimeout() + ViewConfiguration.getLongPressTimeout()) / 2;
mScaledTouchSlop = ViewConfiguration.get(activity).getScaledTouchSlop();
}
示例10: onTimeUpdate
import android.animation.TimeAnimator; //导入依赖的package包/类
/**
* Every TimeAnimator frame, nudge each bouncing view along.
*/
public void onTimeUpdate(TimeAnimator animation, long elapsed, long dt_ms) {
final float dt = dt_ms / 1000f; // seconds
for (int i = 0; i < getChildCount(); i++) {
final View view = getChildAt(i);
final PointF v = (PointF) view.getTag();
// step view for velocity * time
view.setX(view.getX() + v.x * dt);
view.setY(view.getY() + v.y * dt);
// handle reflections
final float l = view.getX();
final float t = view.getY();
final float r = l + view.getWidth();
final float b = t + view.getHeight();
boolean flipX = false, flipY = false;
if (r > mWidth) {
view.setX(view.getX() - 2 * (r - mWidth));
flipX = true;
} else if (l < 0) {
view.setX(-l);
flipX = true;
}
if (b > mHeight) {
view.setY(view.getY() - 2 * (b - mHeight));
flipY = true;
} else if (t < 0) {
view.setY(-t);
flipY = true;
}
if (flipX) v.x *= -1;
if (flipY) v.y *= -1;
}
}
示例11: onTimeUpdate
import android.animation.TimeAnimator; //导入依赖的package包/类
public void onTimeUpdate(TimeAnimator animation, long elapsed, long dt_ms) {
final float dt = dt_ms / 1000f; // seconds
for (int i=0; i<getChildCount(); i++) {
final View view = getChildAt(i);
final PointF v = (PointF) view.getTag();
// step view for velocity * time
view.setX(view.getX() + v.x * dt);
view.setY(view.getY() + v.y * dt);
// handle reflections
final float l = view.getX();
final float t = view.getY();
final float r = l + view.getWidth();
final float b = t + view.getHeight();
boolean flipX = false, flipY = false;
if (r > mWidth) {
view.setX(view.getX() - 2 * (r - mWidth));
flipX = true;
} else if (l < 0) {
view.setX(-l);
flipX = true;
}
if (b > mHeight) {
view.setY(view.getY() - 2 * (b - mHeight));
flipY = true;
} else if (t < 0) {
view.setY(-t);
flipY = true;
}
if (flipX) v.x *= -1;
if (flipY) v.y *= -1;
}
}
示例12: init
import android.animation.TimeAnimator; //导入依赖的package包/类
private void init(Context context) {
animator = new TimeAnimator();
animator.setTimeListener(this);
paint = new Paint();
paint.setColor(Color.WHITE);
density = getResources().getDisplayMetrics().density;
path = new Path();
pathMeasure = new PathMeasure();
position = new PointF();
velocity = new PointF();
}
示例13: onTimeUpdate
import android.animation.TimeAnimator; //导入依赖的package包/类
@Override
public void onTimeUpdate(TimeAnimator animation, long totalTime, long deltaTime) {
float fraction;
if (totalTime >= mDuration) {
fraction = 1;
mAnimator.end();
} else {
fraction = (float) (totalTime / (double) mDuration);
}
if (mInterpolator != null) {
fraction = mInterpolator.getInterpolation(fraction);
}
setFocusLevel(mFocusLevelStart + fraction * mFocusLevelDelta);
}
示例14: SystemClockManager
import android.animation.TimeAnimator; //导入依赖的package包/类
public SystemClockManager(SystemClockListener listener, long resolution) {
mListener = listener;
mResolution = resolution;
mAnimator = new TimeAnimator();
mAnimator.setTimeListener(this);
}
示例15: onTimeUpdate
import android.animation.TimeAnimator; //导入依赖的package包/类
@Override
public void onTimeUpdate(TimeAnimator timeAnimator, long l, long l2) {
long now = l / mResolution;
if (now != mLast) {
mLast = now;
mListener.onTimeChanged(System.currentTimeMillis());
}
}