mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-01 16:26:47 +00:00
Properly prevent All Apps relayouts by avoiding scrollToPosition
Calling scrollToPosition on RecyclerView internally calls requestLayout() (to cacluate where to scroll and then go there). Therefore, we should avoid calling that whenever possible, especially during transitions. In particular, we can optimize scrollToTop() to not scrollToPosition() if we are already at the top. This makes some other workarounds unnecessary, namely setting All Apps to GONE during system gestures. Test: Open an app, swipe up, ensure AllAppsRecyclerView doesn't get onLayout(). If we had scrolled to an app first, we get one layout in prepareRecentsUi(), but not during the transition. Bug: 140308849 Change-Id: I62ee341bf5893c121cfc013cc6542559f79d2a42
This commit is contained in:
@@ -34,6 +34,7 @@ import com.android.launcher3.ItemInfo;
|
||||
import com.android.launcher3.Launcher;
|
||||
import com.android.launcher3.LauncherAppState;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.allapps.AllAppsGridAdapter.AppsGridLayoutManager;
|
||||
import com.android.launcher3.compat.AccessibilityManagerCompat;
|
||||
import com.android.launcher3.logging.StatsLogUtils.LogContainerProvider;
|
||||
import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
|
||||
@@ -113,6 +114,13 @@ public class AllAppsRecyclerView extends BaseRecyclerView implements LogContaine
|
||||
if (mScrollbar != null) {
|
||||
mScrollbar.reattachThumbToScroll();
|
||||
}
|
||||
if (getLayoutManager() instanceof AppsGridLayoutManager) {
|
||||
AppsGridLayoutManager layoutManager = (AppsGridLayoutManager) getLayoutManager();
|
||||
if (layoutManager.findFirstCompletelyVisibleItemPosition() == 0) {
|
||||
// We are at the top, so don't scrollToPosition (would cause unnecessary relayout).
|
||||
return;
|
||||
}
|
||||
}
|
||||
scrollToPosition(0);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user