@Test public void testNullListDivider() { final Context context = InstrumentationRegistry.getContext(); RecyclerView rv = new RecyclerView(context); rv.setLayoutManager(new LinearLayoutManager(context)); rv.setAdapter(new MyAdapter(STRINGS)); DividerItemDecoration decoration = new DividerItemDecoration( new ContextThemeWrapper(context, R.style.nullListDivider), DividerItemDecoration.HORIZONTAL); rv.addItemDecoration(decoration); rv.layout(0, 0, 1000, 1000); decoration.onDraw(new Canvas(), rv, null); }
@Override public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) { if (parent.getLayoutManager() == null || mDivider == null) { return; } if (mOrientation == VERTICAL) { drawVertical(c, parent); } else { drawHorizontal(c, parent); } }
DividerItemDecoration extends RecyclerView.ItemDecoration { @Override public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) { if (parent.getLayoutManager() == null || mDivider == null) { return; } if (mOrientation == VERTICAL) { drawVertical(c, parent); } else { drawHorizontal(c, parent); } } }
DividerItemDecoration extends RecyclerView.ItemDecoration { @Override public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) { if (parent.getLayoutManager() == null || mDivider == null) { return; } if (mOrientation == VERTICAL) { drawVertical(c, parent); } else { drawHorizontal(c, parent); } } DividerItemDecoration(Context context, int orientation); }
DividerItemDecoration extends RecyclerView.ItemDecoration { @Override public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) { if (parent.getLayoutManager() == null || mDivider == null) { return; } if (mOrientation == VERTICAL) { drawVertical(c, parent); } else { drawHorizontal(c, parent); } } DividerItemDecoration(Context context, int orientation); void setOrientation(int orientation); void setDrawable(@NonNull Drawable drawable); @Override void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state); @Override void getItemOffsets(Rect outRect, View view, RecyclerView parent,
            RecyclerView.State state); }
DividerItemDecoration extends RecyclerView.ItemDecoration { @Override public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) { if (parent.getLayoutManager() == null || mDivider == null) { return; } if (mOrientation == VERTICAL) { drawVertical(c, parent); } else { drawHorizontal(c, parent); } } DividerItemDecoration(Context context, int orientation); void setOrientation(int orientation); void setDrawable(@NonNull Drawable drawable); @Override void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state); @Override void getItemOffsets(Rect outRect, View view, RecyclerView parent,
            RecyclerView.State state); static final int HORIZONTAL; static final int VERTICAL; }