Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 025799ba authored by Kevin's avatar Kevin
Browse files

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
parent a4397929
Loading
Loading
Loading
Loading
+0 −14
Original line number Diff line number Diff line
@@ -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);
    }

    /**
+17 −1
Original line number Diff line number Diff line
@@ -45,12 +45,14 @@ import androidx.recyclerview.widget.RecyclerView.OnChildAttachStateChangeListene

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;
import com.android.quickstep.TaskHolder;
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
@@ -105,7 +107,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);
@@ -114,6 +129,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