private void release() { final ViewPager viewPager = mViewPager.get(); if (viewPager != null) { ViewCompat.postOnAnimation( viewPager, new Runnable() { @Override public void run() { viewPager.removeOnPageChangeListener(ViewPagerListener.this); } }); } } }
@UiThread @Override public void onNewLayoutStateReady(ComponentTree componentTree) { if (mMountedView == null) { applyReadyBatches(); } else { // When mounted, always apply binder mutations on frame boundaries ViewCompat.postOnAnimation(mMountedView, mApplyReadyBatchesRunnable); } } };
private void requestRemeasure() { if (SectionsDebug.ENABLED) { Log.d(SectionsDebug.TAG, "(" + hashCode() + ") requestRemeasure"); } if (mMountedView != null) { mMainThreadHandler.removeCallbacks(mRemeasureRunnable); mMountedView.removeCallbacks(mRemeasureRunnable); ViewCompat.postOnAnimation(mMountedView, mRemeasureRunnable); } else { // We are not mounted but we still need to post this. Just post on the main thread. mMainThreadHandler.removeCallbacks(mRemeasureRunnable); mMainThreadHandler.post(mRemeasureRunnable); } }
@Override public void run() { if (startTime == -1) { startTime = System.currentTimeMillis(); } else { long normalizedTime = (1000 * (System.currentTimeMillis() - startTime)) / duration; normalizedTime = Math.max(Math.min(normalizedTime, 1000), 0); final int deltaY = Math.round((scrollFromPosition - scrollToPosition) * interpolator.getInterpolation(normalizedTime / 1000f)); currentPosition = scrollFromPosition - deltaY; moveOverScrollView(currentPosition); } if (scrollToPosition != currentPosition) { ViewCompat.postOnAnimation(OverScrollViewPager.this, this); } } }
private void maybePostUpdateViewportAndComputeRange() { if (mMountedView != null && (mUseSharedLayoutStateFuture || ComponentsConfiguration.insertPostAsyncLayout || mViewportManager.shouldUpdate())) { mMountedView.removeCallbacks(mUpdateViewportRunnable); ViewCompat.postOnAnimation(mMountedView, mUpdateViewportRunnable); } computeRange(mCurrentFirstVisiblePosition, mCurrentLastVisiblePosition); }
private void dimChildView(View v, float mag, int fadeColor) { final LayoutParams lp = (LayoutParams) v.getLayoutParams(); if (mag > 0 && fadeColor != 0) { final int baseAlpha = (fadeColor & 0xff000000) >>> 24; int imag = (int) (baseAlpha * mag); int color = imag << 24 | (fadeColor & 0xffffff); if (lp.dimPaint == null) { lp.dimPaint = new Paint(); } lp.dimPaint.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_OVER)); if (ViewCompat.getLayerType(v) != ViewCompat.LAYER_TYPE_HARDWARE) { ViewCompat.setLayerType(v, ViewCompat.LAYER_TYPE_HARDWARE, lp.dimPaint); } invalidateChildRegion(v); } else if (ViewCompat.getLayerType(v) != ViewCompat.LAYER_TYPE_NONE) { if (lp.dimPaint != null) { lp.dimPaint.setColorFilter(null); } final DisableLayerRunnable dlr = new DisableLayerRunnable(v); mPostedRunnables.add(dlr); ViewCompat.postOnAnimation(this, dlr); } }
viewPager.addOnPageChangeListener(viewPagerListener); } catch (ConcurrentModificationException e) { ViewCompat.postOnAnimation( viewPager, new Runnable() {
ViewCompat.postOnAnimation(this, mEndScrollRunnable); } else { mEndScrollRunnable.run();
ViewCompat.postOnAnimation(this, mEndScrollRunnable); } else { mEndScrollRunnable.run();
ViewCompat.postOnAnimation(this, mEndScrollRunnable); } else { mEndScrollRunnable.run();
@UiThread public void notifyItemRenderCompleteAt(int position, final long timestampMillis) { final ComponentTreeHolder holder = mComponentTreeHolders.get(position); final EventHandler<RenderCompleteEvent> renderCompleteEventHandler = holder.getRenderInfo().getRenderCompleteEventHandler(); if (renderCompleteEventHandler == null) { return; } final @RenderState int state = holder.getRenderState(); if (state != ComponentTreeHolder.RENDER_UNINITIALIZED) { return; } // Dispatch a RenderCompleteEvent asynchronously. ViewCompat.postOnAnimation( mMountedView, new RenderCompleteRunnable( renderCompleteEventHandler, RenderCompleteEvent.RenderState.RENDER_DRAWN, timestampMillis)); // Update the state to prevent dispatch an event again for the same holder. holder.setRenderState(ComponentTreeHolder.RENDER_DRAWN); }
@Override public void run() { if (mMountedView == null || !mMountedView.hasPendingAdapterUpdates()) { if (mViewportManager.shouldUpdate()) { mViewportManager.onViewportChanged(State.DATA_CHANGES); } mPostUpdateViewportAttempts = 0; return; } // If the view gets detached, we might still have pending updates. // If the view's visibility is GONE, layout won't happen until it becomes visible. We have // to exit here, otherwise we keep posting this runnable to the next frame until it // becomes visible. if (!mMountedView.isAttachedToWindow() || mMountedView.getVisibility() == View.GONE) { mPostUpdateViewportAttempts = 0; return; } if (mPostUpdateViewportAttempts >= POST_UPDATE_VIEWPORT_AND_COMPUTE_RANGE_MAX_ATTEMPTS) { mPostUpdateViewportAttempts = 0; if (mViewportManager.shouldUpdate()) { mViewportManager.onViewportChanged(State.DATA_CHANGES); } return; } // If we have pending updates, wait until the sync operations are finished and try again // in the next frame. mPostUpdateViewportAttempts++; ViewCompat.postOnAnimation(mMountedView, mUpdateViewportRunnable); } };
private void startRotating() { ViewCompat.postOnAnimation(this, new Runnable() { @Override public void run() { mCurrentDegree += 10; if (mCurrentDegree > 360) { mCurrentDegree = 0; } if (mIsRefreshing) { startRotating(); } postInvalidate(); } }); }
private void dimChildView(View v, float mag, int fadeColor) { final LayoutParams lp = (LayoutParams) v.getLayoutParams(); if (mag > 0 && fadeColor != 0) { final int baseAlpha = (fadeColor & 0xff000000) >>> 24; int imag = (int) (baseAlpha * mag); int color = imag << 24 | (fadeColor & 0xffffff); if (lp.dimPaint == null) { lp.dimPaint = new Paint(); } lp.dimPaint.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_OVER)); if (ViewCompat.getLayerType(v) != ViewCompat.LAYER_TYPE_HARDWARE) { ViewCompat.setLayerType(v, ViewCompat.LAYER_TYPE_HARDWARE, lp.dimPaint); } invalidateChildRegion(v); } else if (ViewCompat.getLayerType(v) != ViewCompat.LAYER_TYPE_NONE) { if (lp.dimPaint != null) { lp.dimPaint.setColorFilter(null); } final DisableLayerRunnable dlr = new DisableLayerRunnable(v); mPostedRunnables.add(dlr); ViewCompat.postOnAnimation(this, dlr); } }
private void dimChildView(View v, float mag, int fadeColor) { final LayoutParams lp = (LayoutParams) v.getLayoutParams(); if (mag > 0 && fadeColor != 0) { final int baseAlpha = (fadeColor & 0xff000000) >>> 24; int imag = (int) (baseAlpha * mag); int color = imag << 24 | (fadeColor & 0xffffff); if (lp.dimPaint == null) { lp.dimPaint = new Paint(); } lp.dimPaint.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_OVER)); if (ViewCompat.getLayerType(v) != ViewCompat.LAYER_TYPE_HARDWARE) { ViewCompat.setLayerType(v, ViewCompat.LAYER_TYPE_HARDWARE, lp.dimPaint); } invalidateChildRegion(v); } else if (ViewCompat.getLayerType(v) != ViewCompat.LAYER_TYPE_NONE) { if (lp.dimPaint != null) { lp.dimPaint.setColorFilter(null); } final DisableLayerRunnable dlr = new DisableLayerRunnable(v); mPostedRunnables.add(dlr); ViewCompat.postOnAnimation(this, dlr); } }
@Override public void run() { if (dragger.continueSettling(true)) { ViewCompat.postOnAnimation(parent, this); } } };
private void postOnAnimation() { if (mEatRunOnAnimationRequest) { mReSchedulePostAnimationCallback = true; } else { if (recyclerView != null) { recyclerView.removeCallbacks(this); ViewCompat.postOnAnimation(recyclerView, this); } } } }
private void start() { if (mOverScroller.computeScrollOffset()) { mFlingRunnable = new FlingRunnable(mParent, mLayout); ViewCompat.postOnAnimation(mLayout, mFlingRunnable); } else { onFlingFinished(mParent, mLayout); } }
private void start() { if (mOverScroller.computeScrollOffset()) { mFlingRunnable = new FlingRunnable(mParent, mLayout); ViewCompat.postOnAnimation(mLayout, mFlingRunnable); } else { onFlingFinished(mParent, mLayout); } }
private void start() { if (mOverScroller.computeScrollOffset()) { mFlingRunnable = new FlingRunnable(mParent, mLayout); ViewCompat.postOnAnimation(mLayout, mFlingRunnable); } else { onFlingFinished(mParent, mLayout); } }