Search in sources :

Example 1 with QuickMultipleEntity

use of com.chad.baserecyclerviewadapterhelper.entity.QuickMultipleEntity in project BaseRecyclerViewAdapterHelper by CymChad.

the class MultiItemQuickUseActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_multiple_item_use);
    setTitle("BaseMultiItemQuickAdapter");
    setBackBtn();
    RecyclerView mRecyclerView = findViewById(R.id.rv_list);
    final List<QuickMultipleEntity> data = DataServer.getMultipleItemData();
    final MultipleItemQuickAdapter multipleItemAdapter = new MultipleItemQuickAdapter(data);
    final GridLayoutManager manager = new GridLayoutManager(this, 4);
    mRecyclerView.setLayoutManager(manager);
    multipleItemAdapter.setGridSpanSizeLookup(new GridSpanSizeLookup() {

        @Override
        public int getSpanSize(GridLayoutManager gridLayoutManager, int viewType, int position) {
            return data.get(position).getSpanSize();
        }
    });
    mRecyclerView.setAdapter(multipleItemAdapter);
}
Also used : QuickMultipleEntity(com.chad.baserecyclerviewadapterhelper.entity.QuickMultipleEntity) GridSpanSizeLookup(com.chad.library.adapter.base.listener.GridSpanSizeLookup) GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager) RecyclerView(androidx.recyclerview.widget.RecyclerView) MultipleItemQuickAdapter(com.chad.baserecyclerviewadapterhelper.adapter.multi.MultipleItemQuickAdapter)

Example 2 with QuickMultipleEntity

use of com.chad.baserecyclerviewadapterhelper.entity.QuickMultipleEntity in project BaseRecyclerViewAdapterHelper by CymChad.

the class DataServer method getMultipleItemData.

public static List<QuickMultipleEntity> getMultipleItemData() {
    List<QuickMultipleEntity> list = new ArrayList<>();
    for (int i = 0; i <= 4; i++) {
        list.add(new QuickMultipleEntity(QuickMultipleEntity.IMG, QuickMultipleEntity.IMG_SPAN_SIZE));
        list.add(new QuickMultipleEntity(QuickMultipleEntity.TEXT, QuickMultipleEntity.TEXT_SPAN_SIZE, CYM_CHAD));
        list.add(new QuickMultipleEntity(QuickMultipleEntity.IMG_TEXT, QuickMultipleEntity.IMG_TEXT_SPAN_SIZE));
        list.add(new QuickMultipleEntity(QuickMultipleEntity.IMG_TEXT, QuickMultipleEntity.IMG_TEXT_SPAN_SIZE_MIN));
        list.add(new QuickMultipleEntity(QuickMultipleEntity.IMG_TEXT, QuickMultipleEntity.IMG_TEXT_SPAN_SIZE_MIN));
    }
    return list;
}
Also used : QuickMultipleEntity(com.chad.baserecyclerviewadapterhelper.entity.QuickMultipleEntity) ArrayList(java.util.ArrayList)

Aggregations

QuickMultipleEntity (com.chad.baserecyclerviewadapterhelper.entity.QuickMultipleEntity)2 GridLayoutManager (androidx.recyclerview.widget.GridLayoutManager)1 RecyclerView (androidx.recyclerview.widget.RecyclerView)1 MultipleItemQuickAdapter (com.chad.baserecyclerviewadapterhelper.adapter.multi.MultipleItemQuickAdapter)1 GridSpanSizeLookup (com.chad.library.adapter.base.listener.GridSpanSizeLookup)1 ArrayList (java.util.ArrayList)1