1

I am having an issue with my RecyclerView defaultItemAnimator. When I remove one of my items using notifyItemRemoved() I also call notifyItemChanged() on another specific index to change the text in it. During the removal animation, the item I called notifyItemChanged() on changes its text but does some goofy looking animation that sticks out like a sore thumb. (It moves to its new position instantly, while the rest move smoothly to their new positions)

Is there a way to get notified when notifyItemRemoved() completes so I can then call notifyItemChanged()?

yAnTar
  • 4,269
  • 9
  • 47
  • 73
Nick H
  • 8,897
  • 9
  • 41
  • 64
  • checkout this SO Answer [Insert/Remove Animation Recycler View](http://stackoverflow.com/a/32890849/3140227) – Vipul Asri Jan 06 '16 at 12:32

1 Answers1

1

A possible solution is to set a Handler. Get the source code of the Animation class of notifyItemRemoved() and notifyItemChanged(). Inside the Methods should be the lines:

 animation.setDuration(getRemoveDuration())
            .alpha(0).setListener(new VpaListenerAdapter() {
        @Override
        public void onAnimationStart(View view) {
            dispatchRemoveStarting(holder);
        }

Inside the animateRemoveImpl() Methode.

Go to the declaration of the

getRemoveDuration()

And get the value. Set inside a handler with a postDelay of the getRemoveDuration() the notifyItemChange(). Handler could look sth like:

handler.postDelayed(notifyItemChanged, theDurationValue); }
Sebastian
  • 408
  • 1
  • 6
  • 11