workspace: get the correct page when setting paddings

When adding a new page to the workspace, mWorkspaceScreens doesn't
necessarily keeps the order. We should use the mScreenOrder field to get
 the correct index of pages.

Fixes: 197198491
Test: drag an app from first page and paddings should be correct
Change-Id: I4f79c164391348b53b71a87d5d49cfc4d3d35e5a
This commit is contained in:
Thales Lima
2021-08-24 11:54:03 +01:00
parent a7929aff08
commit 41f33c3cfd

View File

@@ -333,7 +333,8 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
int paddingBottom = grid.cellLayoutBottomPaddingPx;
int panelCount = getPanelCount();
for (int i = mWorkspaceScreens.size() - 1; i >= 0; i--) {
int numberOfScreens = mScreenOrder.size();
for (int i = 0; i < numberOfScreens; i++) {
int paddingLeft = paddingLeftRight;
int paddingRight = paddingLeftRight;
if (panelCount > 1) {
@@ -348,7 +349,9 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
paddingRight = 0;
}
}
mWorkspaceScreens.valueAt(i).setPadding(paddingLeft, 0, paddingRight, paddingBottom);
// SparseArrayMap doesn't keep the order
mWorkspaceScreens.get(mScreenOrder.get(i))
.setPadding(paddingLeft, 0, paddingRight, paddingBottom);
}
}