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
This commit is contained in:
parent
fc6781992d
commit
3e98796189
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue