public static void postOnAnimation(View view, Runnable runnable) { // if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) { // SDK16.postOnAnimation(view, runnable); // } else { view.postDelayed(runnable, SIXTY_FPS_INTERVAL); // } }
@Override public void run() { Toast.makeText(PostDelayedDemo.this, "Who-hoo!", Toast.LENGTH_SHORT) .show(); root.postDelayed(this, PERIOD); } }
public void executeAfterDraw(final View view, final Runnable runnable) { view.postDelayed(runnable, Math.max(5, startDelay)); }
public static void postOnAnimation(View view, Runnable runnable) { if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) { postOnAnimationJellyBean(view, runnable); } else { view.postDelayed(runnable, SIXTY_FPS_INTERVAL); } }
private void playSnackOutAnimation() { mSnackOutAnim.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { mTargetView.setVisibility(View.GONE); if (mSnackAnimationCallback != null) { mSnackAnimationCallback.dismissCallback(); } } @Override public void onAnimationRepeat(Animation animation) { } }); mTargetView.postDelayed(new Runnable() { @Override public void run() { mTargetView.startAnimation(mSnackOutAnim); } }, mAutoDismissTime); }
@Override public void run() { if ((SystemClock.uptimeMillis() - lastActivity) > TIMEOUT_PERIOD) { content.setKeepScreenOn(false); } content.postDelayed(this, TIMEOUT_POLL_PERIOD); }
public static void postOnAnimation(View view, Runnable runnable) { if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) { SDK16.postOnAnimation(view, runnable); } else { view.postDelayed(runnable, SIXTY_FPS_INTERVAL); } }
findViewById(R.id.button).setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View button) { button.setBackgroundResource(R.drawable.avatar_dead); final long changeTime = 1000L; button.postDelayed(new Runnable() { @Override public void run() { button.setBackgroundResource(R.drawable.avatar_small); } }, changeTime); } });
private void stop() { mp.stop(); pause.setVisible(false); stop.setVisible(false); findViewById(android.R.id.content).postDelayed(new Runnable() { @Override public void run() { try { mp.prepare(); mp.seekTo(0); play.setVisible(true); } catch (Exception e) { goBlooey(e); } } }, 100); }
private void warn(long delta) { if (delta>7) { String msg=String.format("RVAdapterWrapper violation: ~duration= %d ms", delta); Log.e(TAG, msg, new LogStackTrace()); if (v==null) { WindowManager.LayoutParams params=new WindowManager.LayoutParams( WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE, PixelFormat.TRANSLUCENT); v=new View(host); v.setBackgroundResource(R.drawable.border); wm.addView(v, params); v.postDelayed(new Runnable() { @Override public void run() { wm.removeView(v); v=null; } }, 500); } } }
private void scheduleNextStep() { view.removeCallbacks(this); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { view.postOnAnimationDelayed(this, FRAME_TIME); } else { view.postDelayed(this, FRAME_TIME); } }
@Override public void onBindViewHolder(BaseViewHolder holder, int position) { Object item = getItem(position); if (needHint && holder.itemView.getTag() == null) { holder.itemView.setTag(item); holder.itemView.postDelayed(() -> { holder.mViewDataBinding.setVariable(BR.item, holder.itemView.getTag()); holder.mViewDataBinding.executePendingBindings(); }, 800); } else { if (needHint) holder.itemView.setTag(item); holder.mViewDataBinding.setVariable(BR.item, item); holder.mViewDataBinding.executePendingBindings(); } }
@Override public void run() { int pos = mTick % mCountPerSeg; for (int i = 0; i < mSegCount; i++) { int index = i * mCountPerSeg + pos; if (index > mTick) { continue; } index = index % mItemList.size(); StoreHouseBarItem item = mItemList.get(index); item.setFillAfter(false); item.setFillEnabled(true); item.setFillBefore(false); item.setDuration(mLoadingAniItemDuration); item.start(mFromAlpha, mToAlpha); } mTick++; if (mRunning && mRefreshKernel != null) { final View refreshView = mRefreshKernel.getRefreshLayout().getLayout(); refreshView.postDelayed(this, mInterval); } }
mDisallowIntercept = new DisallowIntercept(); src.postDelayed(mDisallowIntercept, mTapTimeout); if (mTriggerLongPress == null) { mTriggerLongPress = new TriggerLongPress(); src.postDelayed(mTriggerLongPress, mLongPressTimeout); break; case MotionEvent.ACTION_MOVE:
public void animScale(final View likeView) { ScaleAnimation scaleAnimation = new ScaleAnimation(1.0f, 1.5f, 1.0f, 1.5f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); scaleAnimation.setDuration(200); scaleAnimation.setFillAfter(true); scaleAnimation.start(); likeView.startAnimation(scaleAnimation); likeView.postDelayed(new Runnable() { @Override public void run() { ScaleAnimation scaleAnimation = new ScaleAnimation(1.5f, 1.0f, 1.5f, 1.0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); scaleAnimation.setDuration(200); scaleAnimation.setFillAfter(true); likeView.startAnimation(scaleAnimation); } }, 200); }
@Test public void shouldRemovePostedCallbacksFromMessageQueue() throws Exception { TestRunnable runnable = new TestRunnable(); view.postDelayed(runnable, 1); view.removeCallbacks(runnable); Robolectric.getForegroundThreadScheduler().advanceBy(1); assertThat(runnable.wasRun).isFalse(); }
@Override public void onLoadMore(boolean isSilence) { imageLayout.postDelayed(new Runnable() { @Override public void run() { outView.stopLoadMore(); } }, 2000); }
tempHeader.dispatchTouchEvent(transformEvent(ev, mMotionHeaderPosition)); tempHeader.invalidate(); tempHeader.postDelayed(new Runnable() { public void run() { invalidate(0, headerHolder.getTop(), getWidth(), headerHolder.getTop()+headerHolder.getHeight());
@Test public void shouldPostActionsToTheMessageQueueWithDelay() throws Exception { ShadowLooper.pauseMainLooper(); TestRunnable runnable = new TestRunnable(); view.postDelayed(runnable, 1); assertFalse(runnable.wasRun); Robolectric.getForegroundThreadScheduler().advanceBy(1); assertTrue(runnable.wasRun); }
rv.postDelayed(removeRunnable, 3000);