Search in sources :

Example 1 with TreeItemBean

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);
}
Also used : WxarticleItemBean(com.example.jingbin.cloudreader.bean.wanandroid.WxarticleItemBean) CommonTabPagerAdapter(com.example.jingbin.cloudreader.view.CommonTabPagerAdapter) ArrayList(java.util.ArrayList) TreeItemBean(com.example.jingbin.cloudreader.bean.wanandroid.TreeItemBean)

Aggregations

TreeItemBean (com.example.jingbin.cloudreader.bean.wanandroid.TreeItemBean)1 WxarticleItemBean (com.example.jingbin.cloudreader.bean.wanandroid.WxarticleItemBean)1 CommonTabPagerAdapter (com.example.jingbin.cloudreader.view.CommonTabPagerAdapter)1 ArrayList (java.util.ArrayList)1