Merge "Preemptively clear the thumbnail cache as tasks are removed" into ub-launcher3-qt-dev

This commit is contained in:
Winson Chung
2019-05-14 20:48:47 +00:00
committed by Android (Google) Code Review
4 changed files with 29 additions and 0 deletions
@@ -476,6 +476,12 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable {
public void onRecycle() {
resetViewTransforms();
setFullscreenProgress(0);
// Clear any references to the thumbnail (it will be re-read either from the cache or the
// system on next bind)
mSnapshotView.setThumbnail(mTask, null);
if (mTask != null) {
mTask.thumbnail = null;
}
}
@Override
@@ -119,6 +119,16 @@ public class RecentTasksList extends TaskStackChangeListener {
mChangeId++;
}
@Override
public void onTaskRemoved(int taskId) {
for (int i = mTasks.size() - 1; i >= 0; i--) {
if (mTasks.get(i).key.id == taskId) {
mTasks.remove(i);
return;
}
}
}
@Override
public synchronized void onActivityPinned(String packageName, int userId, int taskId,
int stackId) {
@@ -166,6 +166,12 @@ public class RecentsModel extends TaskStackChangeListener {
}
}
@Override
public void onTaskRemoved(int taskId) {
Task.TaskKey dummyKey = new Task.TaskKey(taskId, 0, null, null, 0, 0);
mThumbnailCache.remove(dummyKey);
}
public void setSystemUiProxy(ISystemUiProxy systemUiProxy) {
mSystemUiProxy = systemUiProxy;
}
@@ -186,6 +186,13 @@ public class TaskThumbnailCache {
mCache.evictAll();
}
/**
* Removes the cached thumbnail for the given task.
*/
public void remove(Task.TaskKey key) {
mCache.remove(key);
}
/**
* @return The cache size.
*/