From 3e9879618970066423a1bb51da7c2733a6e1116e Mon Sep 17 00:00:00 2001 From: Kevin Date: Fri, 5 Apr 2019 12:20:22 -0700 Subject: [PATCH] Add layout animation for Recents Go Add a layout animation where views fade in upward in a cascade and play it every time the user goes to Recents. Bug: 114136250 Test: Go to Recents and see cascade animation Change-Id: Ia6fdd344f0bfb46c4d507e50f278a86a4432c2b6 --- .../quickstep/views/IconRecentsView.java | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/go/quickstep/src/com/android/quickstep/views/IconRecentsView.java b/go/quickstep/src/com/android/quickstep/views/IconRecentsView.java index f525c9d9d5..c742be3e85 100644 --- a/go/quickstep/src/com/android/quickstep/views/IconRecentsView.java +++ b/go/quickstep/src/com/android/quickstep/views/IconRecentsView.java @@ -28,6 +28,10 @@ import android.util.AttributeSet; import android.util.FloatProperty; import android.view.View; import android.view.ViewDebug; +import android.view.animation.AlphaAnimation; +import android.view.animation.Animation; +import android.view.animation.AnimationSet; +import android.view.animation.LayoutAnimationController; import android.widget.FrameLayout; import androidx.annotation.NonNull; @@ -69,6 +73,8 @@ public final class IconRecentsView extends FrameLayout { } }; private static final long CROSSFADE_DURATION = 300; + private static final long LAYOUT_ITEM_ANIMATE_IN_DURATION = 150; + private static final long LAYOUT_ITEM_ANIMATE_IN_DELAY_BETWEEN = 40; private static final long ITEM_ANIMATE_OUT_DURATION = 150; private static final long ITEM_ANIMATE_OUT_DELAY_BETWEEN = 40; private static final float ITEM_ANIMATE_OUT_TRANSLATION_X_RATIO = .25f; @@ -84,6 +90,7 @@ public final class IconRecentsView extends FrameLayout { private final TaskListLoader mTaskLoader; private final TaskAdapter mTaskAdapter; private final TaskActionController mTaskActionController; + private final LayoutAnimationController mLayoutAnimation; private RecentsToActivityHelper mActivityHelper; private RecyclerView mTaskRecyclerView; @@ -99,6 +106,7 @@ public final class IconRecentsView extends FrameLayout { mTaskAdapter = new TaskAdapter(mTaskLoader); mTaskActionController = new TaskActionController(mTaskLoader, mTaskAdapter); mTaskAdapter.setActionController(mTaskActionController); + mLayoutAnimation = createLayoutAnimation(); } @Override @@ -112,6 +120,7 @@ public final class IconRecentsView extends FrameLayout { ItemTouchHelper helper = new ItemTouchHelper( new TaskSwipeCallback(mTaskActionController)); helper.attachToRecyclerView(mTaskRecyclerView); + mTaskRecyclerView.setLayoutAnimation(mLayoutAnimation); mEmptyView = findViewById(R.id.recent_task_empty_view); mContentView = findViewById(R.id.recent_task_content_view); @@ -131,7 +140,6 @@ public final class IconRecentsView extends FrameLayout { } } - @Override public void setEnabled(boolean enabled) { super.setEnabled(enabled); @@ -157,6 +165,7 @@ public final class IconRecentsView extends FrameLayout { * becomes visible. */ public void onBeginTransitionToOverview() { + mTaskRecyclerView.scheduleLayoutAnimation(); mTaskAdapter.setIsShowingLoadingUi(true); mTaskAdapter.notifyDataSetChanged(); // Load any task changes @@ -324,4 +333,18 @@ public final class IconRecentsView extends FrameLayout { } }); } + + private static LayoutAnimationController createLayoutAnimation() { + AnimationSet anim = new AnimationSet(false /* shareInterpolator */); + + Animation alphaAnim = new AlphaAnimation(0, 1); + alphaAnim.setDuration(LAYOUT_ITEM_ANIMATE_IN_DURATION); + anim.addAnimation(alphaAnim); + + LayoutAnimationController layoutAnim = new LayoutAnimationController(anim); + layoutAnim.setDelay( + (float) LAYOUT_ITEM_ANIMATE_IN_DELAY_BETWEEN / LAYOUT_ITEM_ANIMATE_IN_DURATION); + + return layoutAnim; + } }