关于PullToRefreshView bug 的修复

原文链接:

http://miloisbadboy.com/archives/93

前几天网友yufengzungzhe@163.com指出PullToRefreshView的一个bug.当时麦洛还没有注意到,现在麦洛已经利用修复了.其实解这个bug也不难.

只要在下面这个方法做一点小小的控制,就可以了

private int changingHeaderViewTopMargin(int deltaY) {
    LayoutParams params = (LayoutParams) mHeaderView.getLayoutParams();
    float newTopMargin = params.topMargin + deltaY * 0.3f;
    //这里对上拉做一下限制,因为当前上拉后然后不释放手指直接下拉,会把下拉刷新给触发了,感谢网友yufengzungzhe的指出
    //表示如果是在上拉后一段距离,然后直接下拉
    if(deltaY>0&&mPullState == PULL_UP_STATE&&Math.abs(params.topMargin) =mHeaderViewHeight){
        return params.topMargin;
    }
    params.topMargin = (int) newTopMargin;
    mHeaderView.setLayoutParams(params);
    invalidate();
    return params.topMargin;
}

再次感谢yufengzungzhe@163.com网友的提示,googlecode上的代码已经更新.
项目地址为

https://code.google.com/p/pull-to-refresh-view/

原文地址:https://www.cnblogs.com/angrycode/p/2645250.html