How to prevent auto scroll in RecyclerView after notifyDataSetChanged?

Viewed 9512

I have a RecyclerView with several items types. It looks like this:

  • 07/21/2017
  • Message 1
  • Message 2
  • Message 3
  • 07/22/2017
  • Message 4
  • New messages header
  • Message 5
  • Message 6

When new messages arrived I sort it by date and call notifyDataSetChanged(). It works well, but it automatically scroll my RecyclerView on new item(s) height. In this case I cannot use notifyItemInserted() because I don't know item position after sorting.

How to force RecyclerView do not scroll after notifyDataSetChanged() without call notifyItemInserted()?

3 Answers
Related