lcodecorex / TwinklingRefreshLayout

RefreshLayout that support for OverScroll and better than iOS. 支持下拉刷新和上拉加载的RefreshLayout,自带越界回弹效果,支持RecyclerView,AbsListView,ScrollView,WebView
Apache License 2.0
4k stars 673 forks source link

Ring setShowArrow 逻辑存在一些小问题 #142

Open ysn85 opened 7 years ago

ysn85 commented 7 years ago

@Override public void onPullingDown(float fraction, float maxHeadHeight, float headHeight) { if (!mIsBeingDragged) { mIsBeingDragged = true; mProgress.setAlpha(STARTING_PROGRESS_ALPHA); }

    mProgress.setIsBeingDragged(mIsBeingDragged); // 新增代码片段
 }

@Override
public void onPullReleasing(float fraction, float maxHeadHeight, float headHeight) {
    mIsBeingDragged = false;
    mProgress.setIsBeingDragged(mIsBeingDragged);

}

在Ring中绘制三角处新增处理逻辑 private void drawTriangle(Canvas c, float startAngle, float sweepAngle, Rect bounds) { if (mArrow == null) { mArrow = new android.graphics.Path(); mArrow.setFillType(android.graphics.Path.FillType.EVEN_ODD); } else { mArrow.reset(); }

        // Adjust the position of the triangle so that it is inset as
        // much as the arc, but also centered on the arc.
        float inset = (int) mStrokeInset / 2 * mArrowScale;
        float x = (float) (mRingCenterRadius * Math.cos(0) + bounds.exactCenterX());
        float y = (float) (mRingCenterRadius * Math.sin(0) + bounds.exactCenterY());

        // Update the path each time. This works around an issue in SKIA
        // where concatenating a rotation matrix to a scale matrix
        // ignored a starting negative rotation. This appears to have
        // been fixed as of API 21.
        mArrow.moveTo(0, 0);
        mArrow.lineTo(mArrowWidth * mArrowScale, 0);
        mArrow.lineTo((mArrowWidth * mArrowScale / 2), (mArrowHeight
                * mArrowScale));
        mArrow.offset(x - inset, y);
        mArrow.close();
        // draw a triangle
        mArrowPaint.setColor(mCurrentColor);
        if (mIsBeingDragged) {
            c.rotate(startAngle + sweepAngle, bounds.exactCenterX(),
                    bounds.exactCenterY());
        } else { // 新增逻辑处理
            c.rotate(startAngle, bounds.exactCenterX(),
                    bounds.exactCenterY());
        }
        c.drawPath(mArrow, mArrowPaint);
    }