Fix workspace scale calculation

- Based on workspace page instead of workspace (takes padding into
  account)
- Checks that width != 0 so we don't divide by 0

Bug: 79526164
Change-Id: I25d92a04550aa34abab7e9e1f93c93dbccd61752
This commit is contained in:
Tony Wickham
2018-05-10 13:58:18 -07:00
parent 5d1873a812
commit 41be2fc783

View File

@@ -50,8 +50,11 @@ public class OverviewState extends LauncherState {
public float[] getWorkspaceScaleAndTranslation(Launcher launcher) {
RecentsView recentsView = launcher.getOverviewPanel();
Workspace workspace = launcher.getWorkspace();
View workspacePage = workspace.getPageAt(workspace.getCurrentPage());
float workspacePageWidth = workspacePage != null && workspacePage.getWidth() != 0
? workspacePage.getWidth() : launcher.getDeviceProfile().availableWidthPx;
recentsView.getTaskSize(sTempRect);
float scale = (float) sTempRect.width() / workspace.getWidth();
float scale = (float) sTempRect.width() / workspacePageWidth;
float parallaxFactor = 0.4f;
return new float[]{scale, 0, -getDefaultSwipeHeight(launcher) * parallaxFactor};
}