From 1060a0d7fc41a61e7b7646265455bd2916ffbdc5 Mon Sep 17 00:00:00 2001 From: Kevin Date: Fri, 12 Apr 2019 09:57:25 -0700 Subject: [PATCH] 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) --- .../AppToOverviewAnimationProvider.java | 7 +++-- .../com/android/quickstep/TaskAdapter.java | 29 ------------------- .../quickstep/views/IconRecentsView.java | 11 ++++--- 3 files changed, 9 insertions(+), 38 deletions(-) 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(); }