Java Code Examples for android.support.v4.view.ViewCompat#postInvalidateOnAnimation()
The following examples show how to use
android.support.v4.view.ViewCompat#postInvalidateOnAnimation() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SlidingUpPanelLayout.java From TurboLauncher with Apache License 2.0 | 6 votes |
/** * Smoothly animate mDraggingPane to the target X position within its range. * * @param slideOffset position to animate to * @param velocity initial velocity in case of fling, or 0. */ boolean smoothSlideTo(float slideOffset, int velocity) { if (!mCanSlide) { // Nothing to do. return false; } final int topBound = getSlidingTop(); int y = mIsSlidingUp ? (int) (topBound + slideOffset * mSlideRange) : (int) (topBound - slideOffset * mSlideRange); if (mDragHelper.smoothSlideViewTo(mSlideableView, mSlideableView.getLeft(), y)) { setAllChildrenVisible(); ViewCompat.postInvalidateOnAnimation(this); return true; } return false; }
Example 2
Source File: CollapsingTextHelper.java From AppCompat-Extension-Library with Apache License 2.0 | 6 votes |
private void calculateOffsets(final float fraction) { interpolateBounds(fraction); mCurrentDrawX = lerp(mExpandedDrawX, mCollapsedDrawX, fraction, mPositionInterpolator); mCurrentDrawY = lerp(mExpandedDrawY, mCollapsedDrawY, fraction, mPositionInterpolator); setInterpolatedTextSize(lerp(mExpandedTextSize, mCollapsedTextSize, fraction, mTextSizeInterpolator)); if (mCollapsedTextColor != mExpandedTextColor) { // If the collapsed and expanded text colors are different, blend them based on the // fraction mTextPaint.setColor(blendColors(mExpandedTextColor, mCollapsedTextColor, fraction)); } else { mTextPaint.setColor(mCollapsedTextColor); } mTextPaint.setShadowLayer( lerp(mExpandedShadowRadius, mCollapsedShadowRadius, fraction, null), lerp(mExpandedShadowDx, mCollapsedShadowDx, fraction, null), lerp(mExpandedShadowDy, mCollapsedShadowDy, fraction, null), blendColors(mExpandedShadowColor, mCollapsedShadowColor, fraction)); ViewCompat.postInvalidateOnAnimation(mView); }
Example 3
Source File: DidiLayout.java From DidiLayout with Apache License 2.0 | 6 votes |
/** * Smoothly animate mDraggingPane to the target X position within its range. * * @param slideOffset position to animate to * @param velocity initial velocity in case of fling, or 0. */ boolean smoothSlideTo(float slideOffset, int velocity) { if (!isEnabled() || mSlideableView == null) { // Nothing to do. return false; } int panelTop = computePanelTopPosition(slideOffset); if (mDragHelper.smoothSlideViewTo(mSlideableView, mSlideableView.getLeft(), panelTop)) { setAllChildrenVisible(); ViewCompat.postInvalidateOnAnimation(this); return true; } return false; }
Example 4
Source File: BothScrollView.java From Nimingban with Apache License 2.0 | 5 votes |
/** * Like {@link View#scrollBy}, but scroll smoothly instead of immediately. * * @param dx the number of pixels to scroll by on the X axis * @param dy the number of pixels to scroll by on the Y axis */ public final void smoothScrollBy(int dx, int dy) { if (getChildCount() == 0) { // Nothing to do. return; } long duration = AnimationUtils.currentAnimationTimeMillis() - mLastScroll; if (duration > ANIMATED_SCROLL_GAP) { final int width = getWidth() - getPaddingRight() - getPaddingLeft(); final int height = getHeight() - getPaddingBottom() - getPaddingTop(); final int right = getChildAt(0).getWidth(); final int bottom = getChildAt(0).getHeight(); final int maxX = Math.max(0, right - width); final int maxY = Math.max(0, bottom - height); final int scrollX = getScrollX(); final int scrollY = getScrollY(); dx = Math.max(0, Math.min(scrollX + dx, maxX)) - scrollX; dy = Math.max(0, Math.min(scrollY + dy, maxY)) - scrollY; mScroller.startScroll(scrollX, scrollY, dx, dy); ViewCompat.postInvalidateOnAnimation(this); } else { if (!mScroller.isFinished()) { mScroller.abortAnimation(); } scrollBy(dx, dy); } mLastScroll = AnimationUtils.currentAnimationTimeMillis(); }
Example 5
Source File: SwipeLayout.java From FragmentRigger with MIT License | 5 votes |
@Override public void computeScroll() { mScrimOpacity = 1 - mScrollPercent; if (mScrimOpacity >= 0) { if (mDragHelper.continueSettling(true)) { ViewCompat.postInvalidateOnAnimation(this); } computeScrollPreView(); } }
Example 6
Source File: SwipeLayout.java From AndroidSwipeLayout with MIT License | 5 votes |
@Override public void computeScroll() { super.computeScroll(); if (mDragHelper.continueSettling(true)) { ViewCompat.postInvalidateOnAnimation(this); } }
Example 7
Source File: BezelImageView.java From v2ex with Apache License 2.0 | 5 votes |
@Override protected void drawableStateChanged() { super.drawableStateChanged(); if (mBorderDrawable != null && mBorderDrawable.isStateful()) { mBorderDrawable.setState(getDrawableState()); } if (mMaskDrawable != null && mMaskDrawable.isStateful()) { mMaskDrawable.setState(getDrawableState()); } if (isDuplicateParentStateEnabled()) { ViewCompat.postInvalidateOnAnimation(this); } }
Example 8
Source File: SlidingUpPanelLayout.java From AntennaPodSP with MIT License | 5 votes |
@Override public void computeScroll() { if (mDragHelper.continueSettling(true)) { if (!mCanSlide) { mDragHelper.abort(); return; } ViewCompat.postInvalidateOnAnimation(this); } }
Example 9
Source File: InkPageIndicator.java From material-intro-screen with MIT License | 5 votes |
private void setJoiningFraction(int leftDot, float fraction) { if (joiningFractions != null) { if (leftDot < joiningFractions.length) { joiningFractions[leftDot] = fraction; ViewCompat.postInvalidateOnAnimation(this); } } }
Example 10
Source File: SlidingUpPanelLayout.java From photo-editor-android with MIT License | 5 votes |
@Override public void computeScroll() { if (mDragHelper != null && mDragHelper.continueSettling(true)) { if (!isEnabled()) { mDragHelper.abort(); return; } ViewCompat.postInvalidateOnAnimation(this); } }
Example 11
Source File: MyDragLayout.java From MyHearts with Apache License 2.0 | 5 votes |
/** * 关闭 * * @param isSmooth 是否平滑的关闭 */ public void close(boolean isSmooth) { int finalLeft = 0; if (isSmooth) { /** * public boolean smoothSlideViewTo(View child, int finalLeft, int finalTop)方法的解释 * * Animate the view <code>child</code> to the given (left, top) position. * If this method returns true, the caller should invoke {@link #continueSettling(boolean)} * on each subsequent frame to continue the motion until it returns false. If this method * returns false there is no further work to do to complete the movement. * * 返回true 代表还没有移动到指定的位置,需要刷新界面,继续移动 * 返回false 就停止工作哈 */ //1、触发动画 if (mDragHelper.smoothSlideViewTo(mMainContent, finalLeft, 0)) { //参数传this,也就是child所在的viewgroup ViewCompat.postInvalidateOnAnimation(this); } } else { //调用layout方法,摆放主布局 /** * @param l Left position, relative to parent * @param t Top position, relative to parent * @param r Right position, relative to parent * @param b Bottom position, relative to parent */ mMainContent.layout(finalLeft, 0, finalLeft + mWidth, finalLeft + mHeight); } }
Example 12
Source File: SwipeBackLayout.java From Cashew with Apache License 2.0 | 5 votes |
@Override public void computeScroll() { mScrimOpacity = 1 - mScrollPercent; if (mDragHelper.continueSettling(true)) { ViewCompat.postInvalidateOnAnimation(this); } }
Example 13
Source File: AbstractChartView.java From SmartChart with Apache License 2.0 | 4 votes |
@Override public void setMaxZoom(float maxZoom) { chartComputator.setMaxZoom(maxZoom); ViewCompat.postInvalidateOnAnimation(this); }
Example 14
Source File: SwipeProgressBar.java From letv with Apache License 2.0 | 4 votes |
void setTriggerPercentage(float triggerPercentage) { this.mTriggerPercentage = triggerPercentage; this.mStartTime = 0; ViewCompat.postInvalidateOnAnimation(this.mParent, this.mBounds.left, this.mBounds.top, this.mBounds.right, this.mBounds.bottom); }
Example 15
Source File: DrawShadowFrameLayout.java From RetailStore with Apache License 2.0 | 4 votes |
@Override public void set(DrawShadowFrameLayout dsfl, Float value) { dsfl.mAlpha = value; ViewCompat.postInvalidateOnAnimation(dsfl); }
Example 16
Source File: EqualizerView.java From Sky31Radio with Apache License 2.0 | 4 votes |
private void updateVisualizerWave(byte[] data) { waveformBytes = data; ViewCompat.postInvalidateOnAnimation(this); }
Example 17
Source File: SlidingLayout.java From UltimateAndroid with Apache License 2.0 | 4 votes |
public void invalidateChildRegion(SlidingLayout parent, View child) { ViewCompat.postInvalidateOnAnimation(parent, child.getLeft(), child.getTop(), child.getRight(), child.getBottom()); }
Example 18
Source File: SwipeBackLayout.java From Readhub with Apache License 2.0 | 4 votes |
private void smoothScrollToX(int finalLeft) { if (viewDragHelper.settleCapturedViewAt(finalLeft, 0)) { ViewCompat.postInvalidateOnAnimation(SwipeBackLayout.this); } }
Example 19
Source File: YViewPagerNew.java From YViewPagerDemo with Apache License 2.0 | 4 votes |
void smoothScrollToVertical(int x, int y, int velocity) { if (getChildCount() == 0) { // Nothing to do. setScrollingCacheEnabled(false); return; } int sy; boolean wasScrolling = (mScroller != null) && !mScroller.isFinished(); if (wasScrolling) { // We're in the middle of a previously initiated scrolling. Check to see // whether that scrolling has actually started (if we always call getStartX // we can get a stale value from the scroller if it hadn't yet had its first // computeScrollOffset call) to decide what is the current scrolling position. sy = mIsScrollStarted ? mScroller.getCurrY() : mScroller.getStartY(); // And abort the current scrolling. mScroller.abortAnimation(); setScrollingCacheEnabled(false); } else { //getScrollX() http://www.bubuko.com/infodetail-916594.html sy = getScrollY(); } int sx = getScrollX(); int dx = x - sx; int dy = y - sy; if (dx == 0 && dy == 0) { // TODO: 2017/2/11 completeScroll completeScrollVertical(false); populateVertical(); setScrollState(SCROLL_STATE_IDLE); return; } setScrollingCacheEnabled(true); setScrollState(SCROLL_STATE_SETTLING); final int height = getClientHeight(); final int halfHeight = height / 2; final float distanceRatio = Math.min(1f, 1.0f * Math.abs(dy) / height); final float distance = halfHeight + halfHeight * distanceInfluenceForSnapDuration(distanceRatio); int duration; velocity = Math.abs(velocity); if (velocity > 0) { duration = 4 * Math.round(1000 * Math.abs(distance / velocity)); } else { final float pageHeight = height * mAdapter.getPageWidth(mCurItem); final float pageDelta = (float) Math.abs(dy) / (pageHeight + mPageMargin); duration = (int) ((pageDelta + 1) * 100); } duration = Math.min(duration, MAX_SETTLE_DURATION); // Reset the "scroll started" flag. It will be flipped to true in all places // where we call computeScrollOffset(). mIsScrollStarted = false; mScroller.startScroll(sx, sy, dx, dy, duration); ViewCompat.postInvalidateOnAnimation(this); }
Example 20
Source File: SwipeRevealLayout.java From SwipeRevealLayoutExample with MIT License | 4 votes |
@Override public void computeScroll() { if (mDragHelper.continueSettling(true)) { ViewCompat.postInvalidateOnAnimation(this); } }