@Override public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) { final RecyclerView.ViewHolder holder = parent.getChildViewHolder(view); final int viewType = holder.getItemViewType(); final FeatureItemDecoration decoration = viewTypeDecorationMap.get(viewType); if (decoration != null) { decoration.getItemOffsetsImpl(outRect, view, holder, parent, state); } }
@Override public void onDraw(Canvas canvas, RecyclerView parent, RecyclerView.State state) { if (parent.getLayoutManager() == null) { return; } for (int i = 0; i < parent.getChildCount(); i++) { final View view = parent.getChildAt(i); final RecyclerView.ViewHolder holder = parent.getChildViewHolder(view); final int viewType = holder.getItemViewType(); final FeatureItemDecoration decoration = viewTypeDecorationMap.get(viewType); if (decoration != null) { decoration.onDrawViewImpl(canvas, view, holder, parent, state); } } } }