Search in sources :

Example 1 with WxarticleItemBean

use of com.example.jingbin.cloudreader.bean.wanandroid.WxarticleItemBean in project CloudReader by youlookwhat.

the class WanFindViewModel method getWxArticle.

public void getWxArticle() {
    Disposable subscribe = HttpClient.Builder.getWanAndroidServer().getWxarticle().subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Consumer<BaseResultBean<List<WxarticleItemBean>>>() {

        @Override
        public void accept(BaseResultBean<List<WxarticleItemBean>> naviJsonBean) throws Exception {
            if (naviJsonBean != null && naviJsonBean.getData() != null && naviJsonBean.getData().size() > 0) {
                // title
                dataTitle.setValue(naviJsonBean.getData());
            } else {
                dataTitle.setValue(null);
            }
        }
    }, new Consumer<Throwable>() {

        @Override
        public void accept(Throwable throwable) throws Exception {
            dataTitle.setValue(null);
        }
    });
    addDisposable(subscribe);
}
Also used : Disposable(io.reactivex.disposables.Disposable) BaseResultBean(com.example.jingbin.cloudreader.bean.wanandroid.BaseResultBean) WxarticleItemBean(com.example.jingbin.cloudreader.bean.wanandroid.WxarticleItemBean) List(java.util.List)

Example 2 with WxarticleItemBean

use of com.example.jingbin.cloudreader.bean.wanandroid.WxarticleItemBean in project CloudReader by youlookwhat.

the class TreeAdapter method bindView.

@Override
protected void bindView(BaseByViewHolder<TreeItemBean> holder, TreeItemBean dataBean, int position) {
    if (dataBean != null) {
        TextView tvTreeTitle = holder.getView(R.id.tv_tree_title);
        FlexboxLayout flTree = holder.getView(R.id.fl_tree);
        String name = DataUtil.getHtmlString(dataBean.getName());
        if (isSelect) {
            flTree.setVisibility(View.GONE);
            if (selectedPosition == position) {
                name = name + "     ★★★";
                tvTreeTitle.setTextColor(CommonUtils.getColor(context, R.color.colorTheme));
            } else {
                tvTreeTitle.setTextColor(CommonUtils.getColor(context, R.color.colorContent));
            }
        } else {
            tvTreeTitle.setTextColor(CommonUtils.getColor(context, R.color.colorContent));
            flTree.setVisibility(View.VISIBLE);
            for (int i = 0; i < dataBean.getChildren().size(); i++) {
                WxarticleItemBean childItem = dataBean.getChildren().get(i);
                TextView child = createOrGetCacheFlexItemTextView(flTree);
                child.setText(DataUtil.getHtmlString(childItem.getName()));
                child.setOnClickListener(v -> CategoryDetailActivity.start(v.getContext(), childItem.getId(), dataBean));
                flTree.addView(child);
            }
        }
        tvTreeTitle.setText(ThinBoldSpan.getDefaultSpanString(tvTreeTitle.getContext(), name));
    }
}
Also used : FlexboxLayout(com.google.android.flexbox.FlexboxLayout) WxarticleItemBean(com.example.jingbin.cloudreader.bean.wanandroid.WxarticleItemBean) TextView(android.widget.TextView)

Example 3 with WxarticleItemBean

use of com.example.jingbin.cloudreader.bean.wanandroid.WxarticleItemBean 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

WxarticleItemBean (com.example.jingbin.cloudreader.bean.wanandroid.WxarticleItemBean)3 TextView (android.widget.TextView)1 BaseResultBean (com.example.jingbin.cloudreader.bean.wanandroid.BaseResultBean)1 TreeItemBean (com.example.jingbin.cloudreader.bean.wanandroid.TreeItemBean)1 CommonTabPagerAdapter (com.example.jingbin.cloudreader.view.CommonTabPagerAdapter)1 FlexboxLayout (com.google.android.flexbox.FlexboxLayout)1 Disposable (io.reactivex.disposables.Disposable)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1