liaoinstan / SpringView

🔥 A custom view pull to refresh,support ScrollView,ListView,RecyclerView,WebView and all another views, easy to use
Apache License 2.0
1.93k stars 355 forks source link

多Fragment Header未还原问题(已解决) #94

Closed sinawangnan7 closed 5 years ago

sinawangnan7 commented 5 years ago

主界面多Fragment的情况,多个页面一起刷新时,每个页面完成都调用了onFinishFreshAndLoad()方法,发现只有当前显示的Fragment顶部Header还原了,其他的还在显示。

之后查了一下原因: SpringView的方法onFinishFreshAndLoad(): 大概是SpringView的797行代码if(isTop()) {} ...只做了if处理没有做else处理。当前页面isTop()是true,其他几个页面isTop()都是false。

最后加了下else处理,把问题解决了(↓):

    public void onFinishFreshAndLoad() {
        if (!isMoveNow && needResetAnim) {
            if (isCallFresh) {
                //手动调用callFresh进行刷新
                if (isTop()) {
                    //检查是否需要执行收场动画
                    if (headerHander != null && headerHander.getEndingAnimTime() > 0) {
                        //需要则,回弹到收场高度
                        resetEndingPosition();
                    } else {
                        //不需要则,直接跳过
                        resetPosition();
                    }
                } else {
                    resetPosition();
                }
                ......
            }
        }
    }
liaoinstan commented 5 years ago

thx