Skip to content

Customization of Composite Items

Vitaly Vivchar edited this page Mar 6, 2020 · 17 revisions

NOTE: start from v3.0.0 ViewBinder was renamed to ViewRenderer, CompositeViewBinder to CompositeViewRenderer

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()));