Animate out/in the correct task view when recents change.
Flag: com.android.launcher3.taskbar_recents_layout_transition Bug: 343521765 Test: go/testedequals Change-Id: I6c7708ed9f03eff8469b5f2e75ce00e545b03f54
This commit is contained in:
@@ -34,6 +34,7 @@ import android.graphics.Canvas;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.util.ArraySet;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.DisplayCutout;
|
||||
import android.view.InputDevice;
|
||||
@@ -74,8 +75,10 @@ import com.android.wm.shell.shared.bubbles.BubbleBarLocation;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
/**
|
||||
@@ -134,6 +137,8 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar
|
||||
|
||||
private final int mNumStaticViews;
|
||||
|
||||
private Set<GroupTask> mPrevRecentTasks = Collections.emptySet();
|
||||
|
||||
public TaskbarView(@NonNull Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
@@ -636,6 +641,7 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar
|
||||
}
|
||||
|
||||
// Add Recent/Running icons.
|
||||
final Set<GroupTask> recentTasksSet = new ArraySet<>(recentTasks);
|
||||
for (GroupTask task : recentTasks) {
|
||||
if (mTaskbarOverflowView != null && overflownTasks != null
|
||||
&& overflownTasks.size() < itemsToAddToOverflow) {
|
||||
@@ -664,12 +670,18 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar
|
||||
}
|
||||
|
||||
View recentIcon = null;
|
||||
while (isNextViewInSection(GroupTask.class)) {
|
||||
// If a task is new, we should not reuse a view so that it animates in when it is added.
|
||||
final boolean canReuseView = !taskbarRecentsLayoutTransition()
|
||||
|| mPrevRecentTasks.contains(task);
|
||||
while (canReuseView && isNextViewInSection(GroupTask.class)) {
|
||||
recentIcon = getChildAt(mNextViewIndex);
|
||||
|
||||
// see if the view can be reused
|
||||
if ((recentIcon.getSourceLayoutResId() != expectedLayoutResId)
|
||||
|| (isCollection && (recentIcon.getTag() != task))) {
|
||||
|| (isCollection && (recentIcon.getTag() != task))
|
||||
// Remove view corresponding to removed task so that it animates out.
|
||||
|| (taskbarRecentsLayoutTransition()
|
||||
&& !recentTasksSet.contains(recentIcon.getTag()))) {
|
||||
removeAndRecycle(recentIcon);
|
||||
recentIcon = null;
|
||||
} else {
|
||||
@@ -699,6 +711,8 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar
|
||||
while (isNextViewInSection(GroupTask.class)) {
|
||||
removeAndRecycle(getChildAt(mNextViewIndex));
|
||||
}
|
||||
|
||||
mPrevRecentTasks = recentTasksSet;
|
||||
}
|
||||
|
||||
private boolean isNextViewInSection(Class<?> tagClass) {
|
||||
|
||||
Reference in New Issue
Block a user