I use RecyclerView with custom ItemDecoration . Moreover, the separators between the cells are different, depending on the types.
When scrolling through the list, everything is OK, but problems begin when using notifyItem *** . In this case, the distance between the cells that are visible on the screen and do not participate in the update, change. After the changes are over, when you scroll again, everything is fine.
Has anyone come across this?
recyclerView.addItemDecoration( new RecyclerView.ItemDecoration() { @Override public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) { int position = linearLayoutManager.getPosition(view); int type = linearLayoutManager.getItemViewType(view); outRect.bottom = getSize( type, messageManager.getType(position + 1) ); outRect.left = 0; outRect.right = 0; outRect.top = getSize( messageManager.getType(position - 1), type ); } private int getSize(int type1, int type2) { if ((type1 & MessageManager.FLAG_MESSAGE) == MessageManager.FLAG_MESSAGE && (type2 & MessageManager.FLAG_MESSAGE) == MessageManager.FLAG_MESSAGE) return (type2 & MessageManager.FLAG_FIRST) == MessageManager.FLAG_FIRST && ((type1 & MessageManager.FLAG_FIRST) == MessageManager.FLAG_FIRST || (type1 & MessageManager.FLAG_FIRST) != MessageManager.FLAG_FIRST) ? Sizes.DP_8 : Sizes.DP_2; return 0; } } );