Fix snapshots not updating on app => overview.

Previously we were only updating the model on snapshot update and not
the view itself, so the view would have an outdated snapshot if it
loaded everything before the data updated itself.

Bug: 114136250
Fixes: 130635650
Test: Go from app to overview, transitions properly with new snapshot
Change-Id: Ife9cae7a700a855788b5d25b05d78e562e1b27f0
(cherry picked from commit 025799ba9c)
This commit is contained in:
Kevin 2019-04-15 17:33:26 -07:00 committed by Kevin Han
parent 9c91de5a9d
commit a94154970a
2 changed files with 17 additions and 15 deletions

View File

@ -38,23 +38,9 @@ public final class TaskListLoader {
private ArrayList<Task> mTaskList = new ArrayList<>();
private int mTaskListChangeId;
private RecentsModel.TaskThumbnailChangeListener listener = (taskId, thumbnailData) -> {
Task foundTask = null;
for (Task task : mTaskList) {
if (task.key.id == taskId) {
foundTask = task;
break;
}
}
if (foundTask != null) {
foundTask.thumbnail = thumbnailData;
}
return foundTask;
};
public TaskListLoader(Context context) {
mRecentsModel = RecentsModel.INSTANCE.get(context);
mRecentsModel.addThumbnailChangeListener(listener);
}
/**

View File

@ -51,6 +51,7 @@ import com.android.launcher3.BaseActivity;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.R;
import com.android.quickstep.ContentFillItemAnimator;
import com.android.quickstep.RecentsModel;
import com.android.quickstep.RecentsToActivityHelper;
import com.android.quickstep.TaskActionController;
import com.android.quickstep.TaskAdapter;
@ -58,6 +59,7 @@ import com.android.quickstep.TaskHolder;
import com.android.quickstep.TaskLayoutManager;
import com.android.quickstep.TaskListLoader;
import com.android.quickstep.TaskSwipeCallback;
import com.android.systemui.shared.recents.model.Task;
/**
* Root view for the icon recents view. Acts as the main interface to the rest of the Launcher code
@ -114,7 +116,20 @@ public final class IconRecentsView extends FrameLayout {
private boolean mTransitionedFromApp;
private AnimatorSet mLayoutAnimation;
private final ArraySet<View> mLayingOutViews = new ArraySet<>();
private final RecentsModel.TaskThumbnailChangeListener listener = (taskId, thumbnailData) -> {
TaskItemView[] itemViews = getTaskViews();
for (TaskItemView taskView : itemViews) {
TaskHolder taskHolder = (TaskHolder) mTaskRecyclerView.getChildViewHolder(taskView);
Task task = taskHolder.getTask();
if (taskHolder.getTask().key.id == taskId) {
// Update thumbnail on the task.
task.thumbnail = thumbnailData;
taskView.setThumbnail(thumbnailData.thumbnail);
return task;
}
}
return null;
};
public IconRecentsView(Context context, AttributeSet attrs) {
super(context, attrs);
@ -125,6 +140,7 @@ public final class IconRecentsView extends FrameLayout {
mTaskAdapter = new TaskAdapter(mTaskLoader);
mTaskActionController = new TaskActionController(mTaskLoader, mTaskAdapter);
mTaskAdapter.setActionController(mTaskActionController);
RecentsModel.INSTANCE.get(context).addThumbnailChangeListener(listener);
}
@Override