-
Notifications
You must be signed in to change notification settings - Fork 184
Customization of Composite Items
Vitaly Vivchar edited this page Oct 19, 2017
·
17 revisions
How to change a LayoutManager
override the createLayoutManager()
method:
public class RecyclerViewRenderer extends CompositeViewRenderer<RecyclerViewModel, RecyclerViewHolder> {
...
@Override
protected RecyclerView.LayoutManager createLayoutManager() {
return new AnyLayoutManager();
}
}
override the createAdapter()
method:
public class RecyclerViewRenderer extends CompositeViewRenderer<RecyclerViewModel, RecyclerViewHolder> {
...
@Override
protected RendererRecyclerViewAdapter createAdapter() {
return new AnyExtendedAdapter();
}
}
How to add any ItemDecoration
override the createItemDecorations()
method:
public class RecyclerViewRenderer extends CompositeViewRenderer<RecyclerViewModel, RecyclerViewHolder> {
...
@Override
protected List<? extends RecyclerView.ItemDecoration> createItemDecorations() {
return Collections.singletonList(new AnyItemDecoration());
}
}
override the bindView
method
public class RecyclerViewRenderer extends CompositeViewRenderer<RecyclerViewModel, RecyclerViewHolder> {
...
@Override
public void bindView(RecyclerViewModel model, RecyclerViewHolder holder) {
...
holder.adapter.setItems(model.getItems(), new AnyDiffCallback());
}
}