@Test public void shouldOverrideCornerWhenTwoLayersCollide() { givenThatThereIsOneCellToRender(); Drawable drawableMock = mock(Drawable.class); Drawable overrideDrawableMock = mock(Drawable.class); when(drawableMock.mutate()).thenReturn(drawableMock); when(overrideDrawableMock.mutate()).thenReturn(overrideDrawableMock); List<Layer> layers = getSingleCornerDrawableLayer(drawableMock); layers.addAll(getSingleCornerDrawableLayer(overrideDrawableMock)); dividerItemDecoration = new DividerItemDecoration(layers); dividerItemDecoration.onDrawOver(canvasMock, recyclerViewMock, recyclerViewStateMock); verify(overrideDrawableMock).draw(Matchers.eq(canvasMock)); }
@Override public void onDrawOver(Canvas canvas, RecyclerView parent, RecyclerView.State state) { if (positionAdapter == null) { positionAdapter = new PositionAdapter(parent.getLayoutManager(), offset); } int childCount = parent.getChildCount(); for (int i = 0; i < childCount; i++) { View child = parent.getChildAt(i); int absolutePosition = parent.getChildAdapterPosition(child); Position position = positionAdapter.getPositionByIndex(absolutePosition); Divider divider = dividerMap.getDivider(position, positionAdapter); drawDivider(canvas, child, divider, position); } }
DividerItemDecoration extends RecyclerView.ItemDecoration { @Override public void onDrawOver(Canvas canvas, RecyclerView parent, RecyclerView.State state) { if (positionAdapter == null) { positionAdapter = new PositionAdapter(parent.getLayoutManager(), offset); } int childCount = parent.getChildCount(); for (int i = 0; i < childCount; i++) { View child = parent.getChildAt(i); int absolutePosition = parent.getChildAdapterPosition(child); Position position = positionAdapter.getPositionByIndex(absolutePosition); Divider divider = dividerMap.getDivider(position, positionAdapter); drawDivider(canvas, child, divider, position); } } }
DividerItemDecoration extends RecyclerView.ItemDecoration { @Override public void onDrawOver(Canvas canvas, RecyclerView parent, RecyclerView.State state) { if (positionAdapter == null) { positionAdapter = new PositionAdapter(parent.getLayoutManager(), offset); } int childCount = parent.getChildCount(); for (int i = 0; i < childCount; i++) { View child = parent.getChildAt(i); int absolutePosition = parent.getChildAdapterPosition(child); Position position = positionAdapter.getPositionByIndex(absolutePosition); Divider divider = dividerMap.getDivider(position, positionAdapter); drawDivider(canvas, child, divider, position); } } DividerItemDecoration(Layer layer, int offset);  DividerItemDecoration(Collection<Layer> layers, int offset);  DividerItemDecoration(Layer layer);  DividerItemDecoration(Collection<Layer> layers); }
DividerItemDecoration extends RecyclerView.ItemDecoration { @Override public void onDrawOver(Canvas canvas, RecyclerView parent, RecyclerView.State state) { if (positionAdapter == null) { positionAdapter = new PositionAdapter(parent.getLayoutManager(), offset); } int childCount = parent.getChildCount(); for (int i = 0; i < childCount; i++) { View child = parent.getChildAt(i); int absolutePosition = parent.getChildAdapterPosition(child); Position position = positionAdapter.getPositionByIndex(absolutePosition); Divider divider = dividerMap.getDivider(position, positionAdapter); drawDivider(canvas, child, divider, position); } } DividerItemDecoration(Layer layer, int offset);  DividerItemDecoration(Collection<Layer> layers, int offset);  DividerItemDecoration(Layer layer);  DividerItemDecoration(Collection<Layer> layers); @Override void onDrawOver(Canvas canvas, RecyclerView parent, RecyclerView.State state); }
DividerItemDecoration extends RecyclerView.ItemDecoration { @Override public void onDrawOver(Canvas canvas, RecyclerView parent, RecyclerView.State state) { if (positionAdapter == null) { positionAdapter = new PositionAdapter(parent.getLayoutManager(), offset); } int childCount = parent.getChildCount(); for (int i = 0; i < childCount; i++) { View child = parent.getChildAt(i); int absolutePosition = parent.getChildAdapterPosition(child); Position position = positionAdapter.getPositionByIndex(absolutePosition); Divider divider = dividerMap.getDivider(position, positionAdapter); drawDivider(canvas, child, divider, position); } } DividerItemDecoration(Layer layer, int offset);  DividerItemDecoration(Collection<Layer> layers, int offset);  DividerItemDecoration(Layer layer);  DividerItemDecoration(Collection<Layer> layers); @Override void onDrawOver(Canvas canvas, RecyclerView parent, RecyclerView.State state);  }