the backend returns 10 pieces of list data. After I successfully load multiple layouts, why is there only 9 of the original 10 pieces of data?
Fragment method for loading multiple layouts:
@Override
protected void onLazyLoad() {
HomeBean homeBean = getArguments().getParcelable(AppExtra.HOME_DATA);
List<HomeBean.FocusEventBean> focusEventBeans = homeBean.getFocus_event();//
List<HomeBean.ArticleInfoBean> articleInfoBean = homeBean.getArticleInfo();//()
mAdapter = new HeadlineAdapter(R.layout.item_home_page, articleInfoBean, homeBean);
//headerview
view = View.inflate(getActivity(), R.layout.home_header_view, null);
mViewPager = view.findViewById(R.id.vp_home_header);
mViewPager.addOnPageChangeListener(this);
mPageList = new ArrayList<>();
for (int i = 0; i < focusEventBeans.size(); iPP) {
//
HomeBean.FocusEventBean gameBean = focusEventBeans.get(i);
HomeGameFragment homeGameFragment = HomeGameFragment.newInstance(gameBean);
FragmentPage fragmentPage = new FragmentPage(homeGameFragment, "");
mPageList.add(fragmentPage);
}
BaseFragmentPagerAdapter adapter = new BaseFragmentPagerAdapter(getChildFragmentManager(), mPageList);
initHeader();//ViewPager
mViewPager.setAdapter(adapter);
mAdapter.addHeaderView(view);
mAdapter.setOnItemClickListener(this);
//
for (int i = 0; i < articleInfoBean.size(); iPP) {
HomeBean.ArticleInfoBean bean = articleInfoBean.get(i);
if (i == 3) {
bean.setLayoutType(HomeBean.ArticleInfoBean.SECOND_TYPE); //item
} else {
bean.setLayoutType(HomeBean.ArticleInfoBean.NORMAL_TYPE);//
}
}
//TODO:
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getActivity());
linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
DividerItemDecoration mDividerItemDecoration = new DividerItemDecoration(getActivity(), linearLayoutManager.getOrientation());
mRecyclerView.addItemDecoration(mDividerItemDecoration);
mRecyclerView.setLayoutManager(linearLayoutManager);
mRecyclerView.setAdapter(mAdapter);//
// mAdapter.notifyItemChanged(2,articleInfoBean.size());
// mAdapter.notifyItemChanged(3);
// mAdapter.notifyItemRangeChanged(2,articleInfoBean.size());
}
Adapter:
public class HeadlineAdapter extends BaseQuickAdapter<HomeBean.ArticleInfoBean, BaseViewHolder> implements BaseQuickAdapter.OnItemClickListener {
private TodayReadAdapter mAdapter;
private List<String> mDatas;
private HomeBean mHomeBean;
public HeadlineAdapter(int layoutResId, @Nullable List<HomeBean.ArticleInfoBean> data,HomeBean homeBean) {
super(layoutResId, data);
this.mHomeBean=homeBean;
setMultiTypeDelegate(new MultiTypeDelegate<HomeBean.ArticleInfoBean>() {
@Override
protected int getItemType(HomeBean.ArticleInfoBean homeListBean) {
return homeListBean.layoutType;//;
}
});
getMultiTypeDelegate()//Recycler
.registerItemType(HomeBean.ArticleInfoBean.NORMAL_TYPE, R.layout.item_home_page)//()
.registerItemType(HomeBean.ArticleInfoBean.SECOND_TYPE, R.layout.today_read);//()
}
@Override
protected void convert(BaseViewHolder helper, HomeBean.ArticleInfoBean item) {
switch (helper.getItemViewType()) {
case HomeBean.ArticleInfoBean.NORMAL_TYPE: //
RequestOptions options = new RequestOptions().placeholder(R.mipmap.temp_banner);
helper.setText(R.id.tv_headerline_title, item.getTitle())//
.setText(R.id.tv_headerline_watch_count, String.valueOf(item.getArticle_hits()));//
Glide.with(mContext).load(item.getLeftFigure()).apply(options).into((ImageView) helper.getView(R.id.iv_headerline));//
break;
case HomeBean.ArticleInfoBean.SECOND_TYPE: //
RecyclerView recyclerView = helper.getView(R.id.rv_today_read);
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(mContext);
linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
recyclerView.setLayoutManager(linearLayoutManager);
if (mAdapter == null) {
mAdapter = new TodayReadAdapter(R.layout.item_today_read, mHomeBean.getMustRead());
recyclerView.setAdapter(mAdapter);
}
mAdapter.setOnItemClickListener(this);
break;
}
}}