Reputation: 8992
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()?
Upvotes: 1
Views: 1176
Reputation: 428
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); }
Upvotes: 1