android.support.v4.view.ViewCompat#postInvalidateOnAnimation ( )源码实例Demo

下面列出了android.support.v4.view.ViewCompat#postInvalidateOnAnimation ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: DidiLayout   文件: DidiLayout.java
/**
 * 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;
}
 
源代码2 项目: TurboLauncher   文件: SlidingUpPanelLayout.java
/**
 * 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;
}
 
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);
}
 
源代码4 项目: FragmentRigger   文件: SwipeLayout.java
@Override
public void computeScroll() {
    mScrimOpacity = 1 - mScrollPercent;
    if (mScrimOpacity >= 0) {
        if (mDragHelper.continueSettling(true)) {
            ViewCompat.postInvalidateOnAnimation(this);
        }
        computeScrollPreView();
    }
}
 
源代码5 项目: AndroidSwipeLayout   文件: SwipeLayout.java
@Override
public void computeScroll() {
    super.computeScroll();
    if (mDragHelper.continueSettling(true)) {
        ViewCompat.postInvalidateOnAnimation(this);
    }
}
 
@Override
public void computeScroll() {
    if (mDragHelper != null && mDragHelper.continueSettling(true)) {
        if (!isEnabled()) {
            mDragHelper.abort();
            return;
        }

        ViewCompat.postInvalidateOnAnimation(this);
    }
}
 
源代码7 项目: Cashew   文件: SwipeBackLayout.java
@Override
public void computeScroll() {
    mScrimOpacity = 1 - mScrollPercent;
    if (mDragHelper.continueSettling(true)) {
        ViewCompat.postInvalidateOnAnimation(this);
    }
}
 
源代码8 项目: MyHearts   文件: MyDragLayout.java
/**
 * 关闭
 *
 * @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);
    }

}
 
源代码9 项目: material-intro-screen   文件: InkPageIndicator.java
private void setJoiningFraction(int leftDot, float fraction) {
    if (joiningFractions != null) {
        if (leftDot < joiningFractions.length) {
            joiningFractions[leftDot] = fraction;
            ViewCompat.postInvalidateOnAnimation(this);
        }
    }
}
 
源代码10 项目: AntennaPodSP   文件: SlidingUpPanelLayout.java
@Override
public void computeScroll() {
    if (mDragHelper.continueSettling(true)) {
        if (!mCanSlide) {
            mDragHelper.abort();
            return;
        }

        ViewCompat.postInvalidateOnAnimation(this);
    }
}
 
源代码11 项目: v2ex   文件: BezelImageView.java
@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);
    }
}
 
源代码12 项目: Nimingban   文件: BothScrollView.java
/**
 * 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();
}
 
@Override
public void computeScroll() {
    if (mDragHelper.continueSettling(true)) {
        ViewCompat.postInvalidateOnAnimation(this);
    }
}
 
源代码14 项目: YViewPagerDemo   文件: YViewPagerNew.java
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);
}
 
源代码15 项目: Readhub   文件: SwipeBackLayout.java
private void smoothScrollToX(int finalLeft) {
    if (viewDragHelper.settleCapturedViewAt(finalLeft, 0)) {
        ViewCompat.postInvalidateOnAnimation(SwipeBackLayout.this);
    }
}
 
源代码16 项目: UltimateAndroid   文件: SlidingLayout.java
public void invalidateChildRegion(SlidingLayout parent, View child) {
    ViewCompat.postInvalidateOnAnimation(parent, child.getLeft(), child.getTop(),
            child.getRight(), child.getBottom());
}
 
源代码17 项目: Sky31Radio   文件: EqualizerView.java
private void updateVisualizerWave(byte[] data) {
    waveformBytes = data;
    ViewCompat.postInvalidateOnAnimation(this);
}
 
源代码18 项目: SmartChart   文件: AbstractChartView.java
@Override
public void setMaxZoom(float maxZoom) {
    chartComputator.setMaxZoom(maxZoom);
    ViewCompat.postInvalidateOnAnimation(this);
}
 
源代码19 项目: RetailStore   文件: DrawShadowFrameLayout.java
@Override
public void set(DrawShadowFrameLayout dsfl, Float value) {
    dsfl.mAlpha = value;
    ViewCompat.postInvalidateOnAnimation(dsfl);
}
 
源代码20 项目: letv   文件: SwipeProgressBar.java
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);
}
 
 同类方法