perf: Cache PreferenceManager2 in memory (#6897)

Signed-off-by: Pun Butrach <pun.butrach@gmail.com>
This commit is contained in:
Pun Butrach authored and GitHub committed 2026-06-19 18:21:55 +00:00
1 parent 5de4bb09fa
commit 83658ce7eb
72 files changed
+338 -238

No files matched your search

@@ -111,7 +111,7 @@ import java.util.Optional;
import java.util.function.Predicate;
import java.util.stream.Stream;
import com.patrykmichalik.opto.core.PreferenceExtensionsKt;
import app.lawnchair.preferences2.PreferenceCacheExtensionsKt;
import static com.topjohnwu.superuser.internal.Utils.context;
import app.lawnchair.allapps.LawnchairAlphabeticalAppsList;
import app.lawnchair.font.FontManager;
@@ -283,7 +283,7 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
* onFinishInflate -> onPostCreate
*/
protected void initContent() {
showFastScroller = PreferenceExtensionsKt.firstBlocking(pref2.getShowScrollbar());
showFastScroller = PreferenceCacheExtensionsKt.firstCached(pref2.getShowScrollbar());
mMainAdapterProvider = mSearchUiDelegate.createMainAdapterProvider();
@@ -543,7 +543,7 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
*/
public void reset(boolean animate, boolean exitSearch) {
// Scroll Main and Work RV to top. Search RV is done in `resetSearch`.
if (!PreferenceExtensionsKt.firstBlocking(pref2.getRememberPosition())) {
if (!PreferenceCacheExtensionsKt.firstCached(pref2.getRememberPosition())) {
for (int i = 0; i < mAH.size(); i++) {
if (i != SEARCH && mAH.get(i).mRecyclerView != null) {
mAH.get(i).mRecyclerView.scrollToTop();
@@ -817,7 +817,7 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
void setupHeader() {
mAdditionalHeaderRows.forEach(row -> mHeader.onPluginDisconnected(row));
var hideHeader = PreferenceExtensionsKt.firstBlocking(pref2.getHideAppDrawerSearchBar());
var hideHeader = PreferenceCacheExtensionsKt.firstCached(pref2.getHideAppDrawerSearchBar());
mHeader.setVisibility(hideHeader ? View.GONE : View.VISIBLE);
boolean tabsHidden = !mUsingTabs;
mHeader.setup(
@@ -870,12 +870,12 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
}
protected void updateHeaderScroll(int scrolledOffset) {
if (PreferenceExtensionsKt.firstBlocking(pref2.getHideAppDrawerSearchBar()))
if (PreferenceCacheExtensionsKt.firstCached(pref2.getHideAppDrawerSearchBar()))
return;
// Check if tab container background should be shown
boolean showTabContainerBackground = PreferenceExtensionsKt.firstBlocking(
pref2.getWorkProfileTabContainerBackground());
boolean showTabContainerBackground = PreferenceCacheExtensionsKt.firstCached(
pref2.getWorkProfileTabContainerBackground(), pref2);
float prog = Utilities.boundToRange((float) scrolledOffset / mHeaderThreshold, 0f, 1f);
int headerColor = getHeaderColor(prog);
@@ -904,8 +904,8 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
protected int getHeaderColor(float blendRatio) {
if (!mActivityContext.getDeviceProfile().shouldShowAllAppsOnSheet()) {
float opacity = mSearchContainer.getAlpha();
var showHeaderBackground = PreferenceExtensionsKt.firstBlocking(
pref2.getAppDrawerSearchBarBackground());
var showHeaderBackground = PreferenceCacheExtensionsKt.firstCached(
pref2.getAppDrawerSearchBarBackground(), pref2);
if (showHeaderBackground) {
opacity = pref.getDrawerOpacity().get();
}
@@ -1034,7 +1034,7 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
private void alignParentTop(View v, boolean includeTabsMargin) {
if (!(v.getLayoutParams() instanceof RelativeLayout.LayoutParams)
|| PreferenceExtensionsKt.firstBlocking(pref2.getHideAppDrawerSearchBar())) {
|| PreferenceCacheExtensionsKt.firstCached(pref2.getHideAppDrawerSearchBar())) {
return;
}
@@ -1049,7 +1049,7 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
private void removeCustomRules(View v) {
if (!(v.getLayoutParams() instanceof RelativeLayout.LayoutParams)
|| PreferenceExtensionsKt.firstBlocking(pref2.getHideAppDrawerSearchBar())) {
|| PreferenceCacheExtensionsKt.firstCached(pref2.getHideAppDrawerSearchBar())) {
return;
}