Fix issue that expanded widgets appear before next item moved down

Issue - http://screen/AYyCKCWZH4uYeBp

* Before - http:/screencast/cast/NTc1NzE0MTg1NDk3ODA0OHwyNjA4ZmU5OC02ZQ
* After - http://screencast/cast/NDcyNTkzNzcyMjYyMTk1MnwxNmU1MTRmNy1jMw

Additionally, also fixes problem that fade in for some expanded sections
didn't always happen.

Bug: 332457155
Flag: N/A
Test: Manual (see video)
Change-Id: Iad3a341d9b992c72b61492d57db4faa96a06ecfa
diff --git a/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java b/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java
index 28eeb10..b3fcefa 100644
--- a/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java
+++ b/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java
@@ -21,6 +21,7 @@
 import static com.android.launcher3.allapps.ActivityAllAppsContainerView.AdapterHolder.SEARCH;
 import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_WIDGETSTRAY_SEARCHED;
 import static com.android.launcher3.testing.shared.TestProtocol.NORMAL_STATE_ORDINAL;
+import static com.android.launcher3.widget.picker.WidgetsListAdapter.VIEW_TYPE_WIDGETS_LIST;
 
 import android.animation.Animator;
 import android.content.Context;
@@ -1094,10 +1095,35 @@
                 default:
                     break;
             }
-            mWidgetsListItemAnimator = new DefaultItemAnimator();
+            mWidgetsListItemAnimator = new DefaultItemAnimator() {
+                @Override
+                public boolean animateChange(RecyclerView.ViewHolder oldHolder,
+                        RecyclerView.ViewHolder newHolder, int fromLeft, int fromTop, int toLeft,
+                        int toTop) {
+                    // As we expand an item, the content / widgets list that appears (with add
+                    // event) also gets change events as its previews load asynchronously. The
+                    // super implementation of animateChange cancels the animations on it - breaking
+                    // the "add animation". Instead, here, we skip "change" animation for content
+                    // list - because we want it to either appear or disappear. And, the previews
+                    // themselves have their own animation when loaded, so, we don't need change
+                    // animations for them anyway. Below, we do-nothing.
+                    if (oldHolder.getItemViewType() == VIEW_TYPE_WIDGETS_LIST) {
+                        dispatchChangeStarting(oldHolder, true);
+                        dispatchChangeFinished(oldHolder, true);
+                        return true;
+                    }
+                    return super.animateChange(oldHolder, newHolder, fromLeft, fromTop, toLeft,
+                            toTop);
+                }
+            };
             // Disable change animations because it disrupts the item focus upon adapter item
             // change.
             mWidgetsListItemAnimator.setSupportsChangeAnimations(false);
+            // Make the moves a bit faster, so that the amount of time for which user sees the
+            // bottom-sheet background before "add" animation starts is less making it smoother.
+            mWidgetsListItemAnimator.setChangeDuration(90);
+            mWidgetsListItemAnimator.setMoveDuration(90);
+            mWidgetsListItemAnimator.setAddDuration(300);
         }
 
         private int getEmptySpaceHeight() {