I don't know why this behaviour is happening, but calling notifyItemInserted(0)
(first position only) won't animate the view. Everything works fine in another positions.
Animation working in this case:
friendsList.remove(positionFriend);
friendsList.add(1, newFriend);
notifyItemInserted(1);
notifyItemRemoved(positionFriend+1);
Animation not working in this case:
friendsList.remove(positionFriend);
friendsList.add(0, newFriend);
notifyItemInserted(0);
notifyItemRemoved(positionFriend+1);
Expected behaviour: Element inserted at the top and insert animation happens there.
What is happening: No insert animation is shown, actually i think 'visually', first element disappears and move animation happens.
the animation happens. But your old position zero becomes position 1 (visible on the screen) and the new position zero appears if you scroll up. So to make it visible you have to scroll the recycler afterwards.
friendsList.remove(positionFriend);
friendsList.add(0, newFriend);
notifyItemInserted(0);
notifyItemRemoved(positionFriend+1);
recycler.scrollToPosition(0);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With