CymChad / CymChad/BaseRecyclerViewAdapterHelper
BaseRecyclerViewAdapterHelper recyclerview 嵌套 recyclerview
Nobody has claimed this yet.
- Dominant language
- Kotlin
- Stars
- 24.6k
- Forks
- 5.2k
- PR merge metrics
- No merged PRs in 30d
Description
当我在首页多布局
首页
View view = inflater.inflate(R.layout.fragment_discover_layout, parent, false);
RecyclerView recyclerView = view.findViewById(R.id.discover_view);
initRefreshLayout(view);
discoverAdapter = new DiscoverAdapter(getContext(),allData);
discoverAdapter.setUseEmpty(false);
// discoverAdapter.isUseEmpty(false);
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext());
linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
// linearLayoutManager.setRecycleChildrenOnDetach(true);
recyclerView.setLayoutManager(linearLayoutManager);
// recyclerView.setHasFixedSize(true);
recyclerView.setAdapter(discoverAdapter);
discoverAdapter.notifyDataSetChanged();
多布局adapter
public DiscoverAdapter(Context context, List data) {
super(data);
this.mContext = context;
addItemType(DiscoverBto.TYPE_DISCOVER_BANNER, R.layout.layout_discover_banner);
addItemType(DiscoverBto.TYPE_DISCOVER_MONTH, R.layout.layout_month_discover_view);
case DiscoverBto.TYPE_DISCOVER_MONTH:
RecyclerView discoverMonthView = (RecyclerView) helper.getView(R.id.discover_view_month);
if (mContext != null) {
DiscoverMonthAdapter storeMonthAdapter = new DiscoverMonthAdapter(R.layout.item_discover_month, item.getMediaList());
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this.mContext);
if (discoverMonthView != null && linearLayoutManager != null) {
linearLayoutManager.setRecycleChildrenOnDetach(true);
linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
discoverMonthView.setLayoutManager(linearLayoutManager);
discoverMonthView.setHasFixedSize(true);
discoverMonthView.setAdapter(storeMonthAdapter);
storeMonthAdapter.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
// ARouter.getInstance().build("/drama/details").navigation();
ARouter.getInstance().build("/audio/circle/player").navigation();
}
});
}
} else {
Log.d("AudioAdapter>>>>", "famous context is null");
}
此处的多布局 BaseMultiItemQuickAdapter 代码没有问题
但是第一次加载都是空白需要拉一下才能展示
首页
<cn.bingoogolapple.refreshlayout.BGARefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/discover_refresh"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:layout_marginTop="@dimen/dp_3"
android:id="@+id/discover_view"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</cn.bingoogolapple.refreshlayout.BGARefreshLayout>
子页嵌套的recyclerview代码也很简单
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/doctor_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
开始我以为是数据加载慢了,但是放在内存缓存里依然出现加载空白
布局管理器肯定是设置了,一直出现需要点一下页面或者切换bottombar 就能瞬间展示不明白什么bug,有么有遇到过
代码是照着例子的多布局写的
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 by reproducing the initial blank rendering described for the homepage RecyclerView and inspect DiscoverAdapter, DiscoverMonthAdapter, and the nested RecyclerViews in fragment_discover_layout and layout_month_discover_view. Compare the initial load with the refresh or bottom-bar switch that makes the items appear. Done means the nested content renders on the first load without a tap, refresh, or navigation change.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100