Only switch item animator on content fill if needed

We currently switch to a different recycler view item animator for a
special content fill animation when we have loading item UI up and want
to animate to the actual content. However, it's possible if the task
content loading is fast enough, we may return before the adapter
changes have actually propogated to the recycler view layout. In this
case there is no loading UI to fill and we should not switch item
animators.

Bug: 130820737
Test: Go from app => overview, try to remove, remove animation occurs
properly
Change-Id: Ic95854d04df98023f444daf967c58bdd8177722a
(cherry picked from commit 035f0d2157)
This commit is contained in:
Kevin 2019-04-18 13:46:47 -07:00 committed by Kevin Han
parent 1866ecf638
commit 56abdd7ade
1 changed files with 7 additions and 3 deletions

View File

@ -243,9 +243,13 @@ public final class IconRecentsView extends FrameLayout {
throw new IllegalStateException("There are less empty item views than the number "
+ "of items to animate to.");
}
// Set item animator for content filling animation. The item animator will switch back
// to the default on completion.
mTaskRecyclerView.setItemAnimator(mLoadingContentItemAnimator);
// Possible that task list loads faster than adapter changes propagate to layout so
// only start content fill animation if there aren't any pending adapter changes.
if (!mTaskRecyclerView.hasPendingAdapterUpdates()) {
// Set item animator for content filling animation. The item animator will switch
// back to the default on completion
mTaskRecyclerView.setItemAnimator(mLoadingContentItemAnimator);
}
mTaskAdapter.notifyItemRangeRemoved(numActualItems, numEmptyItems - numActualItems);
mTaskAdapter.notifyItemRangeChanged(
0, numActualItems, CHANGE_EVENT_TYPE_EMPTY_TO_CONTENT);