Animate to bottom view in app => overview
We always want to animate to the bottom so we should just do that if we
have the view laid out even if at the time the app task doesn't actually
match the view.
Bug: 114136250
Test: Go to recents, press overview twice quickly, see it animate
correctly
Change-Id: I0516ef127ff6ef0f865c85314c9ffe4a7c6ef9e3
(cherry picked from commit 86957f28fff4c3b68f4ea81d48a29b42c53e8176)
diff --git a/go/quickstep/src/com/android/quickstep/AppToOverviewAnimationProvider.java b/go/quickstep/src/com/android/quickstep/AppToOverviewAnimationProvider.java
index d1d697c..c228bb9 100644
--- a/go/quickstep/src/com/android/quickstep/AppToOverviewAnimationProvider.java
+++ b/go/quickstep/src/com/android/quickstep/AppToOverviewAnimationProvider.java
@@ -131,10 +131,11 @@
return anim;
}
- View thumbnailView = mRecentsView.getThumbnailViewForTask(mTargetTaskId);
+ View thumbnailView = mRecentsView.getBottomThumbnailView();
if (thumbnailView == null) {
- // TODO: We should either 1) guarantee the view is loaded before attempting this
- // or 2) have a backup animation.
+ // This can be null if there were previously 0 tasks and the recycler view has not had
+ // enough time to take in the data change, bind a new view, and lay out the new view.
+ // TODO: Have a fallback to animate to
if (Log.isLoggable(TAG, Log.WARN)) {
Log.w(TAG, "No thumbnail view for running task. Using stub animation.");
}
diff --git a/go/quickstep/src/com/android/quickstep/TaskAdapter.java b/go/quickstep/src/com/android/quickstep/TaskAdapter.java
index 66c074b..02cbf4e 100644
--- a/go/quickstep/src/com/android/quickstep/TaskAdapter.java
+++ b/go/quickstep/src/com/android/quickstep/TaskAdapter.java
@@ -15,12 +15,10 @@
*/
package com.android.quickstep;
-import android.util.ArrayMap;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView.Adapter;
import com.android.launcher3.R;
@@ -39,7 +37,6 @@
private static final int MAX_TASKS_TO_DISPLAY = 6;
private static final String TAG = "TaskAdapter";
private final TaskListLoader mLoader;
- private final ArrayMap<Integer, TaskItemView> mTaskIdToViewMap = new ArrayMap<>();
private TaskActionController mTaskActionController;
private boolean mIsShowingLoadingUi;
@@ -63,16 +60,6 @@
mIsShowingLoadingUi = isShowingLoadingUi;
}
- /**
- * Get task item view for a given task id if it's attached to the view.
- *
- * @param taskId task id to search for
- * @return corresponding task item view if it's attached, null otherwise
- */
- public @Nullable TaskItemView getTaskItemView(int taskId) {
- return mTaskIdToViewMap.get(taskId);
- }
-
@Override
public TaskHolder onCreateViewHolder(ViewGroup parent, int viewType) {
TaskItemView itemView = (TaskItemView) LayoutInflater.from(parent.getContext())
@@ -117,22 +104,6 @@
}
@Override
- public void onViewAttachedToWindow(@NonNull TaskHolder holder) {
- if (holder.getTask() == null) {
- return;
- }
- mTaskIdToViewMap.put(holder.getTask().key.id, (TaskItemView) holder.itemView);
- }
-
- @Override
- public void onViewDetachedFromWindow(@NonNull TaskHolder holder) {
- if (holder.getTask() == null) {
- return;
- }
- mTaskIdToViewMap.remove(holder.getTask().key.id);
- }
-
- @Override
public int getItemCount() {
if (mIsShowingLoadingUi) {
// Show loading version of all items.
diff --git a/go/quickstep/src/com/android/quickstep/views/IconRecentsView.java b/go/quickstep/src/com/android/quickstep/views/IconRecentsView.java
index 7f77b6c..59755bc 100644
--- a/go/quickstep/src/com/android/quickstep/views/IconRecentsView.java
+++ b/go/quickstep/src/com/android/quickstep/views/IconRecentsView.java
@@ -225,16 +225,15 @@
}
/**
- * Get the thumbnail view associated with a task for the purposes of animation.
+ * Get the bottom most thumbnail view to animate to.
*
- * @param taskId task id of thumbnail view to get
- * @return the thumbnail view for the task if attached, null otherwise
+ * @return the thumbnail view if laid out
*/
- public @Nullable View getThumbnailViewForTask(int taskId) {
- TaskItemView view = mTaskAdapter.getTaskItemView(taskId);
- if (view == null) {
+ public @Nullable View getBottomThumbnailView() {
+ if (mTaskRecyclerView.getChildCount() == 0) {
return null;
}
+ TaskItemView view = (TaskItemView) mTaskRecyclerView.getChildAt(0);
return view.getThumbnailView();
}