Search in sources :

Example 1 with ChildrenBean

use of com.yumore.provider.entity.reseult.ChildrenBean in project RxMVP by Yumore.

the class CategoryAdapter method convert.

@Override
protected void convert(BaseViewHolder helper, KnowledgeSystem item) {
    if (item == null) {
        return;
    }
    helper.setText(R.id.item_life_title, item.getName());
    FlexboxLayoutManager flexboxLayoutManager = new FlexboxLayoutManager(mContext);
    flexboxLayoutManager.setFlexDirection(FlexDirection.ROW);
    flexboxLayoutManager.setFlexWrap(FlexWrap.WRAP);
    flexboxLayoutManager.setJustifyContent(JustifyContent.FLEX_START);
    RecyclerView recyclerView = helper.getView(R.id.item_life_list);
    recyclerView.setLayoutManager(flexboxLayoutManager);
    CateTagAdapter childAdapter = new CateTagAdapter(R.layout.item_life_child_recycler_list, item.getChildren());
    recyclerView.setAdapter(childAdapter);
    childAdapter.setOnItemClickListener((adapter, view, position) -> {
        if (onItemTagClickListener == null) {
            return;
        }
        ChildrenBean data = item.getChildren().get(position);
        if (item.getLastId() != data.getId()) {
            for (ChildrenBean childrenBean : item.getChildren()) {
                childrenBean.setSelected(childrenBean.getId() == data.getId());
            }
            item.setLastId(data.getId());
            childAdapter.notifyDataSetChanged();
        }
        onItemTagClickListener.onItemTagClick(adapter, view, helper.getAdapterPosition(), position);
    });
    helper.setVisible(R.id.item_life_holder, helper.getAdapterPosition() == 0);
}
Also used : FlexboxLayoutManager(com.google.android.flexbox.FlexboxLayoutManager) ChildrenBean(com.yumore.provider.entity.reseult.ChildrenBean) RecyclerView(androidx.recyclerview.widget.RecyclerView)

Example 2 with ChildrenBean

use of com.yumore.provider.entity.reseult.ChildrenBean in project RxMVP by Yumore.

the class CategoryFragment method onItemTagClick.

@Override
public void onItemTagClick(BaseQuickAdapter<?, ?> adapter, View view, int parentId, int position) {
    KnowledgeSystem knowledgeSystem = knowledgeSystems.get(parentId);
    ChildrenBean childrenBean = knowledgeSystem.getChildren().get(position);
    startActivity(new Intent(getContext(), KnowledgeActivity.class).putExtra("title", childrenBean.getName()).putExtra("cid", childrenBean.getId()));
}
Also used : KnowledgeSystem(com.yumore.provider.entity.reseult.KnowledgeSystem) ChildrenBean(com.yumore.provider.entity.reseult.ChildrenBean) Intent(android.content.Intent) KnowledgeActivity(com.yumore.module.activity.KnowledgeActivity)

Aggregations

ChildrenBean (com.yumore.provider.entity.reseult.ChildrenBean)2 Intent (android.content.Intent)1 RecyclerView (androidx.recyclerview.widget.RecyclerView)1 FlexboxLayoutManager (com.google.android.flexbox.FlexboxLayoutManager)1 KnowledgeActivity (com.yumore.module.activity.KnowledgeActivity)1 KnowledgeSystem (com.yumore.provider.entity.reseult.KnowledgeSystem)1