Skip to content

Customization of Composite Items

Vitaly Vivchar edited this page Feb 17, 2018 · 17 revisions

LayoutManager

To change LayoutManager extend CompositeViewBinder and override the createLayoutManager() method:

public class YourCompositeViewBinder extends CompositeViewBinder<YourCompositeModel> {
	//...
	@Override
	protected RecyclerView.LayoutManager createLayoutManager() {
		return new AnyLayoutManager();
	}
}

Adapter

To set custom RendererRecyclerViewAdapter extend CompositeViewBinder and override createAdapter() method:

public class YourCompositeViewBinder extends CompositeViewBinder<YourCompositeModel> {
	//...
	@Override
	protected RendererRecyclerViewAdapter createAdapter() {
		return new AnyExtendedAdapter();
	}
}

ItemDecoration

To add any ItemDecoration extend CompositeViewBinder and override createItemDecorations() method:

public class YourCompositeViewBinder extends CompositeViewBinder<YourCompositeModel> {
	//...
	@Override
	protected List<? extends RecyclerView.ItemDecoration> createItemDecorations() {
		return Collections.singletonList(new AnyItemDecoration());
	}
}

OR use a special constructor:

new CompositeViewBinder(R.layout.composite_item,
			R.id.nested_recycler_view_id,
			YourCompositeModel.class,
			Collections.singletonList(new AnyItemDecoration()));