天天看點

關于PullToRefreshView bug 的修複

原文連結: http://miloisbadboy.com/archives/93

前幾天網友[email protected]指出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;
}      

再次感謝[email protected]網友的提示,googlecode上的代碼已經更新.

項目位址為

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

繼續閱讀