Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

上拉加载延迟 #263

Closed
wwluo14 opened this issue Jan 5, 2018 · 5 comments
Closed

上拉加载延迟 #263

wwluo14 opened this issue Jan 5, 2018 · 5 comments

Comments

@wwluo14
Copy link

wwluo14 commented Jan 5, 2018

design 包使用25.3.1 CoordinatorLayout 配合LRecyclerView 上拉加载 正常。
design 包使用26以上 CoordinatorLayout 配合LRecyclerView 上拉加载 会导致 滑动到最底部的时候,footView 一片空白, 大约延迟1~2s footView 才会显示出来, 体验不好。

使用design 26 的原因是:因为需要ToolBar 随着 LRecyclerView滑动到最顶部时, 也一起滑动。design 包25 不会一起滑动,26解决了这个bug。可是使用26又会出现上面说的问题。

请问有没有好的解法?

@jdsjlzx
Copy link
Owner

jdsjlzx commented Jan 9, 2018

你好,此问题我也复现了,我会尽快解决!如果你有好的方案,也可以分享!

@wwluo14
Copy link
Author

wwluo14 commented Jan 11, 2018

是的, 上拉加载的触发 在方法 onScrollStateChanged() 中, 我发现在design 26 中可能是google修复了顶部滚动的原因,导致recyclerView 滚动到底部的时候,还会再有一点缓冲时间, 这时候滚动状态就不及时了。 我的改动方法是: 把之前的触发上拉加载的判断 加到 onScrollChanged() 方法中, 然后也把 currentScrollState == RecyclerView.SCROLL_STATE_IDLE 这个判断去掉。 验证后可行!

@jdsjlzx
Copy link
Owner

jdsjlzx commented Jan 30, 2018

感谢分享方案,新版本修正此问题!

@leasual
Copy link

leasual commented Jul 25, 2018

发现,如果用力的往上滑动,上拉加载后,位置并没有停留在刷新前的位置,还会继续往上滑动。

@leasual
Copy link

leasual commented Jul 25, 2018

个人解决的办法是在onScrolled方法中,判定到是显示加载更多view时,如果处于RecyclerView.SCROLL_STATE_SETTLING状态,则停止滚动,

if (mLoadMoreListener != null && mLoadMoreEnabled) {
            int visibleItemCount = layoutManager.getChildCount();
            int totalItemCount = layoutManager.getItemCount();
            if (visibleItemCount > 0
                    && lastVisibleItemPosition >= totalItemCount - 1
                    && totalItemCount > visibleItemCount
                    && !isNoMore
                    && !mRefreshing) {
                mFootView.setVisibility(View.VISIBLE);
                if (!mLoadingData) {
                    mLoadingData = true;
                    mLoadMoreFooter.onLoading();
                    mLoadMoreListener.onLoadMore();
                    if (currentScrollState == RecyclerView.SCROLL_STATE_SETTLING) {
                        new Handler().postDelayed(new Runnable() {
                            @Override
                            public void run() {
                                stopRecyclerViewScroll();
                            }
                        }, 100);
                    }
                }
            }
        }
}

public void stopRecyclerViewScroll() {
        this.stopScroll();
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants