diff --git a/go/quickstep/src/com/android/quickstep/AppToOverviewAnimationProvider.java b/go/quickstep/src/com/android/quickstep/AppToOverviewAnimationProvider.java index d1d697c0cd..c228bb94fe 100644 --- a/go/quickstep/src/com/android/quickstep/AppToOverviewAnimationProvider.java +++ b/go/quickstep/src/com/android/quickstep/AppToOverviewAnimationProvider.java @@ -131,10 +131,11 @@ final class AppToOverviewAnimationProvider imple 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 66c074bddf..02cbf4e010 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 @@ public final class TaskAdapter extends Adapter { private static final int MAX_TASKS_TO_DISPLAY = 6; private static final String TAG = "TaskAdapter"; private final TaskListLoader mLoader; - private final ArrayMap mTaskIdToViewMap = new ArrayMap<>(); private TaskActionController mTaskActionController; private boolean mIsShowingLoadingUi; @@ -63,16 +60,6 @@ public final class TaskAdapter extends Adapter { 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()) @@ -116,22 +103,6 @@ public final class TaskAdapter extends Adapter { super.onBindViewHolder(holder, position, payloads); } - @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) { diff --git a/go/quickstep/src/com/android/quickstep/views/IconRecentsView.java b/go/quickstep/src/com/android/quickstep/views/IconRecentsView.java index 7f77b6cc4d..59755bcb39 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 @@ public final class IconRecentsView extends FrameLayout { } /** - * 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(); }