CymChad / CymChad/BaseRecyclerViewAdapterHelper
BaseDifferAdapter+QuickAdapterHelper(尾部加载更多)会出现recyclerView默认直接自动滑倒底部BUG
Nobody has claimed this yet.
- Dominant language
- Kotlin
- Stars
- 24.6k
- Forks
- 5.2k
- PR merge metrics
- No merged PRs in 30d
Description
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> result) {
if (refreshLayout.isRefreshing()) {
refreshLayout.setRefreshing(false);
}
if (result.isRequestSucceed()) {
List 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方法,而且会出现自动滑动到底部
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the initAdapter and onHttpSuccess methods shown in the report, focusing on QuickAdapterHelper, TrailingLoadStateAdapter, and the 4.1.4 dependency. Reproduce the sequence after setTrailingLoadState(new LoadState.NotLoading(false)) and trace why onLoad runs and the RecyclerView scrolls to the bottom. Done means the state update no longer triggers unintended loading or automatic scrolling.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, kotlin
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100