mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-03 17:36:49 +00:00
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:
@@ -102,7 +102,6 @@ import com.android.launcher3.util.Executors;
|
||||
import com.android.launcher3.util.IntArray;
|
||||
import com.android.launcher3.util.IntSet;
|
||||
import com.android.launcher3.util.IntSparseArrayMap;
|
||||
import com.android.launcher3.util.ItemInfoMatcher;
|
||||
import com.android.launcher3.util.LauncherBindableItemsContainer;
|
||||
import com.android.launcher3.util.OverlayEdgeEffect;
|
||||
import com.android.launcher3.util.PackageUserKey;
|
||||
@@ -3235,7 +3234,7 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
|
||||
* as a part of an update, this is called to ensure that other widgets and application
|
||||
* shortcuts are not removed.
|
||||
*/
|
||||
public void removeItemsByMatcher(final ItemInfoMatcher matcher) {
|
||||
public void removeItemsByMatcher(final Predicate<ItemInfo> matcher) {
|
||||
for (CellLayout layout : getWorkspaceAndHotseatCellLayouts()) {
|
||||
ShortcutAndWidgetContainer container = layout.getShortcutsAndWidgets();
|
||||
// Iterate in reverse order as we are removing items
|
||||
@@ -3243,7 +3242,7 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
|
||||
View child = container.getChildAt(i);
|
||||
ItemInfo info = (ItemInfo) child.getTag();
|
||||
|
||||
if (matcher.matchesInfo(info)) {
|
||||
if (matcher.test(info)) {
|
||||
layout.removeViewInLayout(child);
|
||||
if (child instanceof DropTarget) {
|
||||
mDragController.removeDropTarget((DropTarget) child);
|
||||
@@ -3251,7 +3250,7 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
|
||||
} else if (child instanceof FolderIcon) {
|
||||
FolderInfo folderInfo = (FolderInfo) info;
|
||||
List<WorkspaceItemInfo> matches = folderInfo.contents.stream()
|
||||
.filter(matcher::matchesInfo)
|
||||
.filter(matcher)
|
||||
.collect(Collectors.toList());
|
||||
if (!matches.isEmpty()) {
|
||||
folderInfo.removeAll(matches, false);
|
||||
@@ -3330,7 +3329,7 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
|
||||
*
|
||||
* @param matcher the matcher generated by the caller.
|
||||
*/
|
||||
public void persistRemoveItemsByMatcher(ItemInfoMatcher matcher) {
|
||||
public void persistRemoveItemsByMatcher(Predicate<ItemInfo> matcher) {
|
||||
mLauncher.getModelWriter().deleteItemsFromDatabase(matcher);
|
||||
removeItemsByMatcher(matcher);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user