public boolean postAtTime(Runnable r, long uptimeMillis) { return mHandler.postAtTime(r, uptimeMillis); }
public boolean postAtTime(Runnable r, Object token, long uptimeMillis) { return mHandler.postAtTime(r, token, uptimeMillis); }
@Override public void run() { if (downView == null) { return; } handler.removeCallbacksAndMessages(downView); handler.postAtTime(this, downView, SystemClock.uptimeMillis() + normalInterval); clickListener.onClick(downView); } };
@Override public void run() { if (downView == null) { return; } handler.removeCallbacksAndMessages(downView); handler.postAtTime(this, downView, SystemClock.uptimeMillis() + normalInterval); clickListener.onClick(downView); } };
@Implementation protected void postFrameCallbackDelayed(final FrameCallback callback, long delayMillis) { handler.postAtTime(new Runnable() { @Override public void run() { callback.doFrame(getFrameTimeNanos()); } }, callback, SystemClock.uptimeMillis() + delayMillis); }
/** * Store a new task in the map for providing cancellation. This method is used * by AndroidAnnotations and not intended to be called by clients. * * @param id * the identifier of the task * @param task * the task itself * @param delay * the delay or zero to run immediately */ public static void runTask(String id, Runnable task, long delay) { if ("".equals(id)) { HANDLER.postDelayed(task, delay); return; } long time = SystemClock.uptimeMillis() + delay; HANDLER.postAtTime(task, nextToken(id), time); }
@Override public void run() { onTimeChanged(); long now = SystemClock.uptimeMillis(); long next = now + (1000 - now % 1000); getHandler().postAtTime(mTicker, next); } };
@Override public void run() { long curTime = SystemClock.uptimeMillis(); float progress = Math.min(1f, (float)(curTime - mStartTime) / mAnimDuration); float value = mInterpolator.getInterpolation(progress); mIcon.setAlpha(Math.round(255 * value)); mPrevIcon.setAlpha(Math.round(255 * (1f - value))); if(progress == 1f) stopAnimation(); if(mRunning) { if(getHandler() != null) getHandler().postAtTime(this, SystemClock.uptimeMillis() + ViewUtil.FRAME_DURATION); else stopAnimation(); } invalidate(); }
private void update(){ long curTime = SystemClock.uptimeMillis(); float progress = Math.min(1f, (float)(curTime - mStartTime) / mAnimDuration); float value = mInterpolator.getInterpolation(progress); mThumbPosition = mChecked ? (mStartPosition * (1 - value) + value) : (mStartPosition * (1 - value)); if(progress == 1f) stopAnimation(); if(mRunning) { if(getHandler() != null) getHandler().postAtTime(mUpdater, SystemClock.uptimeMillis() + ViewUtil.FRAME_DURATION); else stopAnimation(); } invalidate(); }
private void update(){ long curTime = SystemClock.uptimeMillis(); mAnimProgress = Math.min(1f, (float)(curTime - mStartTime) / mAnimDuration); if(mAnimProgress == 1f) stopAnimation(); if(mRunning) { if(getHandler() != null) getHandler().postAtTime(mUpdater, SystemClock.uptimeMillis() + ViewUtil.FRAME_DURATION); else stopAnimation(); } invalidate(); }
private void update(){ long curTime = SystemClock.uptimeMillis(); mAnimProgress = Math.min(1f, (float)(curTime - mStartTime) / mAnimDuration); if(mAnimProgress == 1f) stopAnimation(); if(mRunning) { if(getHandler() != null) getHandler().postAtTime(mUpdater, SystemClock.uptimeMillis() + ViewUtil.FRAME_DURATION); else stopAnimation(); } invalidate(); }
@Override public void run() { long curTime = SystemClock.uptimeMillis(); float progress = Math.min(1f, (float)(curTime - mStartTime) / mTransformAnimationDuration); float value = mInterpolator.getInterpolation(progress); mThumbFillPercent = mAlwaysFillThumb ? 1 : ((mFillPercent - mStartFillPercent) * value + mStartFillPercent); if(progress == 1f) stopAnimation(); if(mRunning) { if(getHandler() != null) getHandler().postAtTime(this, SystemClock.uptimeMillis() + ViewUtil.FRAME_DURATION); else stopAnimation(); } invalidate(); }
@Override public void run() { long curTime = SystemClock.uptimeMillis(); float progress = Math.min(1f, (float)(curTime - mStartTime) / mTransformAnimationDuration); float value = mInterpolator.getInterpolation(progress); mThumbCurrentRadius = (mRadius - mStartRadius) * value + mStartRadius; if(progress == 1f) stopAnimation(); if(mRunning) { if(getHandler() != null) getHandler().postAtTime(this, SystemClock.uptimeMillis() + ViewUtil.FRAME_DURATION); else stopAnimation(); } invalidate(); }
private void startAnimation() { if(getHandler() != null){ resetAnimation(); mRunning = true; getHandler().postAtTime(mUpdater, SystemClock.uptimeMillis() + ViewUtil.FRAME_DURATION); } invalidate(); }
private void startAnimation() { if(getHandler() != null){ resetAnimation(); mRunning = true; getHandler().postAtTime(mUpdater, SystemClock.uptimeMillis() + ViewUtil.FRAME_DURATION); } else mThumbPosition = mChecked ? 1f : 0f; invalidate(); }
private void startAnimation() { if(getHandler() != null){ resetAnimation(); mRunning = true; getHandler().postAtTime(mUpdater, SystemClock.uptimeMillis() + ViewUtil.FRAME_DURATION); } invalidate(); }
public boolean startAnimation(int fillPercent) { if(mThumbFillPercent == fillPercent) return false; mFillPercent = fillPercent; if(getHandler() != null){ resetAnimation(); mRunning = true; getHandler().postAtTime(this, SystemClock.uptimeMillis() + ViewUtil.FRAME_DURATION); invalidate(); return true; } else { mThumbFillPercent = mAlwaysFillThumb ? 1 : mFillPercent; invalidate(); return false; } }
public boolean startAnimation(float position) { if(mThumbPosition == position) return false; mPosition = position; if(getHandler() != null){ resetAnimation(); mRunning = true; getHandler().postAtTime(this, SystemClock.uptimeMillis() + ViewUtil.FRAME_DURATION); invalidate(); return true; } else { mThumbPosition = position; invalidate(); return false; } }
public boolean startAnimation(int radius) { if(mThumbCurrentRadius == radius) return false; mRadius = radius; if(getHandler() != null){ resetAnimation(); mRunning = true; getHandler().postAtTime(this, SystemClock.uptimeMillis() + ViewUtil.FRAME_DURATION); invalidate(); return true; } else { mThumbCurrentRadius = mRadius; invalidate(); return false; } }
@Test public void shouldRemoveTaggedCallback() throws Exception { ShadowLooper.pauseMainLooper(); Handler handler = new Handler(); final int[] count = new int[1]; Runnable r = new Runnable() { @Override public void run() { count[0]++; } }; String tag1 = "tag1", tag2 = "tag2"; handler.postAtTime(r, tag1, 100); handler.postAtTime(r, tag2, 105); handler.removeCallbacks(r, tag2); ShadowLooper.unPauseMainLooper(); assertThat(count[0]).named("run count").isEqualTo(1); // This assertion proves that it was the first runnable that ran, // which proves that the correctly tagged runnable was removed. assertThat(shadowOf(handler.getLooper()).getScheduler().getCurrentTime()).named("currentTime").isEqualTo(100); }