Replacing ItemInfoMatcher with predicate

This removed unnecessary componentName lookups when it
is not required. Many checks just rely on IDs and
userHandle

Bug: 231153610
Test: Presubmit
Change-Id: Ief93954abc5861062a9f55dc2ef181d3de106c62
This commit is contained in:
Sunny Goyal
2022-05-02 10:00:07 -07:00
parent 34f51fbfc4
commit 32084d49d3
18 changed files with 106 additions and 147 deletions

View File

@@ -36,6 +36,7 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.function.Predicate;
/**
* Launcher model Callbacks for rendering taskbar.
@@ -126,16 +127,16 @@ public class TaskbarModelCallbacks implements
}
@Override
public void bindWorkspaceComponentsRemoved(ItemInfoMatcher matcher) {
public void bindWorkspaceComponentsRemoved(Predicate<ItemInfo> matcher) {
if (handleItemsRemoved(matcher)) {
commitItemsToUI();
}
}
private boolean handleItemsRemoved(ItemInfoMatcher matcher) {
private boolean handleItemsRemoved(Predicate<ItemInfo> matcher) {
boolean modified = false;
for (int i = mHotseatItems.size() - 1; i >= 0; i--) {
if (matcher.matchesInfo(mHotseatItems.valueAt(i))) {
if (matcher.test(mHotseatItems.valueAt(i))) {
modified = true;
mHotseatItems.removeAt(i);
}