本文整理汇总了Java中android.os.SystemClock.uptimeMillis方法的典型用法代码示例。如果您正苦于以下问题:Java SystemClock.uptimeMillis方法的具体用法?Java SystemClock.uptimeMillis怎么用?Java SystemClock.uptimeMillis使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.os.SystemClock
的用法示例。
在下文中一共展示了SystemClock.uptimeMillis方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doWork
import android.os.SystemClock; //导入方法依赖的package包/类
@Override
public void doWork() {
final long invalidationDelay = mGifDrawable.mNativeInfoHandle.renderFrame(mGifDrawable.mBuffer);
if (invalidationDelay >= 0) {
mGifDrawable.mNextFrameRenderTime = SystemClock.uptimeMillis() + invalidationDelay;
if (mGifDrawable.isVisible()) {
if (mGifDrawable.mIsRunning && !mGifDrawable.mIsRenderingTriggeredOnDraw) {
mGifDrawable.mExecutor.schedule(this, invalidationDelay, TimeUnit.MILLISECONDS);
}
}
if (!mGifDrawable.mListeners.isEmpty() && mGifDrawable.getCurrentFrameIndex() == mGifDrawable.mNativeInfoHandle.frameCount - 1) {
mGifDrawable.scheduleSelf(mNotifyListenersTask, mGifDrawable.mNextFrameRenderTime);
}
} else {
mGifDrawable.mNextFrameRenderTime = Long.MIN_VALUE;
mGifDrawable.mIsRunning = false;
}
if (mGifDrawable.isVisible() && !mGifDrawable.mInvalidationHandler.hasMessages(0)) {
mGifDrawable.mInvalidationHandler.sendEmptyMessageAtTime(0, 0);
}
}
示例2: onLongPress
import android.os.SystemClock; //导入方法依赖的package包/类
@Override
public void onLongPress(MotionEvent e) {
if (callback != null) {
callback.onLongClick(e.getX(), e.getY());
}
long downTime = SystemClock.uptimeMillis();
long eventTime = SystemClock.uptimeMillis() + 100;
float x = 0.0f;
float y = 0.0f;
int metaState = 0;
MotionEvent event = MotionEvent.obtain(
downTime,
eventTime,
MotionEvent.ACTION_CANCEL,
x,
y,
metaState
);
view.dispatchTouchEvent(event);
// onUpEvent(e);
}
示例3: onRestoreInstanceState
import android.os.SystemClock; //导入方法依赖的package包/类
@Override
public void onRestoreInstanceState(Parcelable state) {
if (!(state instanceof ProgressSavedState)) {
super.onRestoreInstanceState(state);
return;
}
ProgressSavedState ss = (ProgressSavedState) state;
super.onRestoreInstanceState(ss.getSuperState());
this.mCurrentProgress = ss.mCurrentProgress;
this.mTargetProgress = ss.mTargetProgress;
this.mSpinSpeed = ss.mSpinSpeed;
this.mProgressWidth = ss.mProgressWidth;
this.mProgressColor = ss.mProgressColor;
this.mProgressBackgroundColor = ss.mProgressBackgroundColor;
this.mShouldProgressIndeterminate = ss.mShouldProgressIndeterminate;
this.mShouldSetProgress = ss.mShouldSetProgress;
this.mProgress = ss.mProgress;
this.mAnimateProgress = ss.mAnimateProgress;
this.mShowProgressBackground = ss.mShowProgressBackground;
this.mLastTimeAnimated = SystemClock.uptimeMillis();
}
示例4: loadNextFrame
import android.os.SystemClock; //导入方法依赖的package包/类
private void loadNextFrame() {
if (!isRunning || isLoadPending) {
return;
}
if (startFromFirstFrame) {
gifDecoder.resetFrameIndex();
startFromFirstFrame = false;
}
isLoadPending = true;
// Get the delay before incrementing the pointer because the delay indicates the amount of time
// we want to spend on the current frame.
int delay = gifDecoder.getNextDelay();
long targetTime = SystemClock.uptimeMillis() + delay;
gifDecoder.advance();
next = new DelayTarget(handler, gifDecoder.getCurrentFrameIndex(), targetTime);
requestBuilder.clone().apply(signatureOf(new FrameSignature())).load(gifDecoder).into(next);
}
示例5: onDrawFrame
import android.os.SystemClock; //导入方法依赖的package包/类
@Override
public void onDrawFrame(GL10 gl) {
gl.glClearColor(1.f, 0.f, 0.f, 1.f);
gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
gl.glLoadIdentity();
gl.glTranslatef(0.f, 0.f, -50.f);
long time = SystemClock.uptimeMillis() % 4000L;
float angle = 0.090f * ((int) time);
gl.glRotatef(angle, 0.f, 0.f, 1.f);
gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
gl.glColor4f(1.f, 1.f, 1.f, 1.f);
gl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertexBuffer);
gl.glDrawElements(GL10.GL_TRIANGLES, indices.length, GL10.GL_UNSIGNED_SHORT, indexBuffer);
gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
}
示例6: beginFakeDrag
import android.os.SystemClock; //导入方法依赖的package包/类
/**
* Start a fake drag of the pager.
*
* @return true if the fake drag began successfully, false if it could not be started.
*/
public boolean beginFakeDrag() {
if (mIsBeingDragged) {
return false;
}
mFakeDragging = true;
setScrollState(SCROLL_STATE_DRAGGING);
if (isHorizontal()) {
mInitialMotionX = mLastMotionX = 0;
} else {
mInitialMotionY = mLastMotionY = 0;
}
if (mVelocityTracker == null) {
mVelocityTracker = VelocityTracker.obtain();
} else {
mVelocityTracker.clear();
}
final long time = SystemClock.uptimeMillis();
final MotionEvent ev = MotionEvent.obtain(time, time, MotionEvent.ACTION_DOWN, 0, 0, 0);
mVelocityTracker.addMovement(ev);
ev.recycle();
mFakeDragBeginTime = time;
return true;
}
示例7: run
import android.os.SystemClock; //导入方法依赖的package包/类
@Override
public void run() {
long elapsed = SystemClock.uptimeMillis() - start;
if (elapsed > duration) {
isAnimationStarted = false;
handler.removeCallbacks(runnable);
chart.setChartRotation((int) targetRotation, false);
animationListener.onAnimationFinished();
return;
}
float scale = Math.min(interpolator.getInterpolation((float) elapsed / duration), 1);
float rotation = startRotation + (targetRotation - startRotation) * scale;
rotation = (rotation % 360 + 360) % 360;
chart.setChartRotation((int) rotation, false);
handler.postDelayed(this, 16);
}
示例8: run
import android.os.SystemClock; //导入方法依赖的package包/类
@Override
public void run() {
long currentTime = SystemClock.uptimeMillis();
long diff = currentTime - mStartTime;
if (diff < mDuration) {
float interpolation = mInterpolator.getInterpolation((float) diff / (float) mDuration);
scheduleSelf(mUpdater, currentTime + FRAME_DURATION);
updateAnimation(interpolation);
} else {
unscheduleSelf(mUpdater);
mRunning = false;
updateAnimation(1f);
notifyFinishedToListener();
}
}
示例9: waitForIdle
import android.os.SystemClock; //导入方法依赖的package包/类
private void waitForIdle() {
// Wait until the either we're stopped or the other threads are done.
// This way we don't start loading all apps until the workspace has settled
// down.
synchronized (LoaderTask.this) {
final long workspaceWaitTime = DEBUG_LOADERS ? SystemClock.uptimeMillis() : 0;
mHandler.postIdle(new Runnable() {
public void run() {
synchronized (LoaderTask.this) {
mLoadAndBindStepFinished = true;
if (DEBUG_LOADERS) {
Log.d(TAG, "done with previous binding step");
}
LoaderTask.this.notify();
}
}
});
while (!mStopped && !mLoadAndBindStepFinished) {
try {
// Just in case mFlushingWorkerThread changes but we aren't woken up,
// wait no longer than 1sec at a time
this.wait(1000);
} catch (InterruptedException ex) {
// Ignore
}
}
if (DEBUG_LOADERS) {
Log.d(TAG, "waited "
+ (SystemClock.uptimeMillis()-workspaceWaitTime)
+ "ms for previous step to finish binding");
}
}
}
示例10: run
import android.os.SystemClock; //导入方法依赖的package包/类
@Override
public void run() {
long currentTime = SystemClock.uptimeMillis();
long diff = currentTime - mStartTime;
if (diff < mDuration) {
float interpolation = mInterpolator.getInterpolation((float) diff / (float) mDuration);
scheduleSelf(mUpdater, currentTime + FRAME_DURATION);
updateAnimation(interpolation);
} else {
unscheduleSelf(mUpdater);
mRunning = false;
updateAnimation(1f);
}
}
示例11: flingWheel
import android.os.SystemClock; //导入方法依赖的package包/类
private void flingWheel() {
mIsDraggingWheel = false;
mVelocityTracker.computeCurrentVelocity(1);
//torque = r X F
mForceVector.set(mVelocityTracker.getXVelocity(), mVelocityTracker.getYVelocity());
setRadiusVector(mLastWheelTouchX, mLastWheelTouchY);
float torque = mForceVector.crossProduct(mRadiusVector);
//dw/dt = torque / I = torque / mr^2
float wheelRadiusSquared = mWheelBounds.getRadius() * mWheelBounds.getRadius();
float angularAccel = torque / wheelRadiusSquared;
//estimate an angular velocity based on the strength of the angular acceleration
float angularVel = angularAccel * ANGULAR_VEL_COEFFICIENT;
//clamp the angular velocity
if (angularVel > MAX_ANGULAR_VEL) angularVel = MAX_ANGULAR_VEL;
else if (angularVel < -MAX_ANGULAR_VEL) angularVel = -MAX_ANGULAR_VEL;
mAngularVelocity = angularVel;
mLastUpdateTime = SystemClock.uptimeMillis();
mRequiresUpdate = true;
invalidate();
}
示例12: dispatchOnCancelled
import android.os.SystemClock; //导入方法依赖的package包/类
void dispatchOnCancelled(LoadTask task, D data) {
onCanceled(data);
if (this.mCancellingTask == task) {
rollbackContentChanged();
this.mLastLoadCompleteTime = SystemClock.uptimeMillis();
this.mCancellingTask = null;
executePendingTask();
}
}
示例13: onVisibilityChanged
import android.os.SystemClock; //导入方法依赖的package包/类
@Override protected void onVisibilityChanged(@NonNull View changedView, int visibility) {
super.onVisibilityChanged(changedView, visibility);
if (visibility == VISIBLE) {
lastTimeAnimated = SystemClock.uptimeMillis();
}
}
示例14: onVisibilityChanged
import android.os.SystemClock; //导入方法依赖的package包/类
@Override protected void onVisibilityChanged(View changedView, int visibility) {
super.onVisibilityChanged(changedView, visibility);
if (visibility == VISIBLE) {
lastTimeAnimated = SystemClock.uptimeMillis();
}
}
示例15: setProgress
import android.os.SystemClock; //导入方法依赖的package包/类
public synchronized void setProgress(int progress, boolean animate) {
if (mProgressIndeterminate) return;
mProgress = progress;
mAnimateProgress = animate;
if (!mButtonPositionSaved) {
mShouldSetProgress = true;
return;
}
mProgressBarEnabled = true;
mShouldUpdateButtonPosition = true;
setupProgressBounds();
saveButtonOriginalPosition();
updateBackground();
if (progress < 0) {
progress = 0;
} else if (progress > mProgressMax) {
progress = mProgressMax;
}
if (progress == mTargetProgress) {
return;
}
mTargetProgress = mProgressMax > 0 ? (progress / (float) mProgressMax) * 360 : 0;
mLastTimeAnimated = SystemClock.uptimeMillis();
if (!animate) {
mCurrentProgress = mTargetProgress;
}
invalidate();
}