use of com.example.jingbin.cloudreader.bean.wanandroid.TreeItemBean in project CloudReader by youlookwhat.
the class CategoryDetailActivity method initData.
private void initData() {
int cid = getIntent().getIntExtra("cid", 0);
TreeItemBean mTreeBean = (TreeItemBean) getIntent().getSerializableExtra("CategoryBean");
bindingView.setTreeItemBean(mTreeBean);
List<String> mTitleList = new ArrayList<>();
int initIndex = 0;
for (int i = 0, len = mTreeBean.getChildren().size(); i < len; i++) {
WxarticleItemBean childrenBean = mTreeBean.getChildren().get(i);
mTitleList.add(childrenBean.getName());
if (childrenBean.getId() == cid) {
initIndex = i;
}
}
CommonTabPagerAdapter myAdapter = new CommonTabPagerAdapter(getSupportFragmentManager(), mTitleList);
myAdapter.setListener(position -> CategoryArticleFragment.newInstance(mTreeBean.getChildren().get(position).getId(), mTreeBean.getChildren().get(position).getName(), false));
bindingView.viewPager.setAdapter(myAdapter);
myAdapter.notifyDataSetChanged();
bindingView.tabLayout.setupWithViewPager(bindingView.viewPager);
// 设置初始位置
bindingView.viewPager.setCurrentItem(initIndex);
}
Aggregations