Search in sources :

Example 1 with MultipleItemQuickAdapter

use of com.chad.baserecyclerviewadapterhelper.adapter.multi.MultipleItemQuickAdapter 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)

Aggregations

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