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:
@@ -58,7 +58,7 @@ import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.allapps.search.SearchAdapterProvider;
|
||||
import com.android.launcher3.keyboard.FocusedItemDecorator;
|
||||
import com.android.launcher3.model.StringCache;
|
||||
import com.android.launcher3.model.data.AppInfo;
|
||||
import com.android.launcher3.model.data.ItemInfo;
|
||||
import com.android.launcher3.util.ItemInfoMatcher;
|
||||
import com.android.launcher3.util.Themes;
|
||||
import com.android.launcher3.views.ActivityContext;
|
||||
@@ -69,6 +69,8 @@ import com.android.launcher3.workprofile.PersonalWorkSlidingTabStrip.OnActivePag
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* Base all apps view container.
|
||||
@@ -91,7 +93,7 @@ public abstract class BaseAllAppsContainerView<T extends Context & ActivityConte
|
||||
/** Context of an activity or window that is inflating this container. */
|
||||
protected final T mActivityContext;
|
||||
protected final List<AdapterHolder> mAH;
|
||||
protected final ItemInfoMatcher mPersonalMatcher = ItemInfoMatcher.ofUser(
|
||||
protected final Predicate<ItemInfo> mPersonalMatcher = ItemInfoMatcher.ofUser(
|
||||
Process.myUserHandle());
|
||||
private final SearchAdapterProvider<?> mMainAdapterProvider;
|
||||
private final AllAppsStore mAllAppsStore = new AllAppsStore();
|
||||
@@ -229,17 +231,10 @@ public abstract class BaseAllAppsContainerView<T extends Context & ActivityConte
|
||||
}
|
||||
|
||||
private void onAppsUpdated() {
|
||||
boolean hasWorkApps = false;
|
||||
for (AppInfo app : mAllAppsStore.getApps()) {
|
||||
if (mWorkManager.getMatcher().matches(app, null)) {
|
||||
hasWorkApps = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
mHasWorkApps = hasWorkApps;
|
||||
mHasWorkApps = Stream.of(mAllAppsStore.getApps()).anyMatch(mWorkManager.getMatcher());
|
||||
if (!mAH.get(AdapterHolder.MAIN).mAppsList.hasFilter()) {
|
||||
rebindAdapters();
|
||||
if (hasWorkApps) {
|
||||
if (mHasWorkApps) {
|
||||
mWorkManager.reset();
|
||||
}
|
||||
}
|
||||
@@ -731,7 +726,7 @@ public abstract class BaseAllAppsContainerView<T extends Context & ActivityConte
|
||||
mLayoutManager = adapter.getLayoutManager();
|
||||
}
|
||||
|
||||
void setup(@NonNull View rv, @Nullable ItemInfoMatcher matcher) {
|
||||
void setup(@NonNull View rv, @Nullable Predicate<ItemInfo> matcher) {
|
||||
mAppsList.updateItemFilter(matcher);
|
||||
mRecyclerView = (AllAppsRecyclerView) rv;
|
||||
mRecyclerView.setEdgeEffectFactory(createEdgeEffectFactory());
|
||||
|
||||
Reference in New Issue
Block a user