BaseRecyclerViewAdapterHelper icon indicating copy to clipboard operation
BaseRecyclerViewAdapterHelper copied to clipboard

BaseDifferAdapter+QuickAdapterHelper(尾部加载更多)会出现recyclerView默认直接自动滑倒底部BUG

Open jmhe1 opened this issue 1 year ago • 3 comments

private void initAdapter() { linearLayoutManager = new LinearLayoutManager(getAttachActivity()); linearLayoutManager.setStackFromEnd(false); recyclerView.setLayoutManager(linearLayoutManager); recyclerView.addItemDecoration(new VerticalItemDecoration(getResources().getDimensionPixelSize(R.dimen.dp_2), getColor(R.color.common_line_color))); mDiscoverAdapter = new DiscoverAdapter();

    helper = new QuickAdapterHelper.Builder(mDiscoverAdapter)
            .setTrailingLoadStateAdapter(new TrailingLoadStateAdapter.OnTrailingListener() {
                @Override
                public void onLoad() {
                    request();
                }

                @Override
                public void onFailRetry() {
                    request();
                }

                @Override
                public boolean isAllowLoading() {
                    return !refreshLayout.isRefreshing();
                }
            }).build();
    recyclerView.setItemAnimator(null);
    recyclerView.setAdapter(helper.getAdapter());
}

public void onHttpSuccess(HttpData<List<DynamicModel>> result) { if (refreshLayout.isRefreshing()) { refreshLayout.setRefreshing(false); } if (result.isRequestSucceed()) { List<DynamicModel> resultList = result.getContent(); if (resultList.isEmpty()) { helper.setTrailingLoadState(new LoadState.NotLoading(true)); if (pageInfo.isFirstPage()) { showEmpty(); } else { showComplete(); } return; } dynamicList.addAll(resultList); mDiscoverAdapter.submitList(dynamicList); helper.setTrailingLoadState(new LoadState.NotLoading(false)); showComplete(); pageInfo.nextPage(); } }

implementation "io.github.cymchad:BaseRecyclerViewAdapterHelper4:4.1.4"

出现的问题是: 执行helper.setTrailingLoadState(new LoadState.NotLoading(false));之后会执行onLoad方法,而且会出现自动滑动到底部

jmhe1 avatar Aug 23 '24 13:08 jmhe1

请问解决了吗,我也出现这个问题

chen-chen-99 avatar Jan 23 '25 09:01 chen-chen-99

原因是尾部Adapter的view先展示出来并成为了焦点,所以等内容加载出来时候等于是往前插的数据,尾部view依然展示。可以尝试在内容Adapter里添加stateView并将isStateViewEnable=true,这样当内容为空时内容的recyclerView会有一个stateView成为焦点,等内容加载出来时候就会从头显示。

yesworks-net avatar Mar 19 '25 03:03 yesworks-net

问题 +1

Acoee avatar Oct 27 '25 09:10 Acoee