2D recents: fix layout to show 3 tasks on a single line

am: 776f6bacd6

Change-Id: I73cda7b837f91b78714db90c06617302201389fd
This commit is contained in:
Manu Cornet
2017-01-31 23:31:14 +00:00
committed by android-build-merger

View File

@@ -74,11 +74,8 @@ public class TaskGridLayoutAlgorithm {
yOffsets = new int[taskCount]; yOffsets = new int[taskCount];
int layoutTaskCount = Math.min(MAX_LAYOUT_TASK_COUNT, taskCount); int layoutTaskCount = Math.min(MAX_LAYOUT_TASK_COUNT, taskCount);
tasksPerLine = getTasksPerLine(layoutTaskCount);
tasksPerLine = layoutTaskCount < 2 ? 1 : ( lines = layoutTaskCount < 4 ? 1 : 2;
layoutTaskCount < 5 ? 2 : (
layoutTaskCount < 7 ? 3 : 4));
lines = layoutTaskCount < 3 ? 1 : 2;
// A couple of special cases. // A couple of special cases.
boolean landscapeWindow = mWindowRect.width() > mWindowRect.height(); boolean landscapeWindow = mWindowRect.width() > mWindowRect.height();
@@ -131,6 +128,27 @@ public class TaskGridLayoutAlgorithm {
emptySpaceY / 2 + mPaddingTopBottom + (taskHeight + mPaddingTaskView) * yIndex; emptySpaceY / 2 + mPaddingTopBottom + (taskHeight + mPaddingTaskView) * yIndex;
} }
} }
private int getTasksPerLine(int taskCount) {
switch(taskCount) {
case 0:
return 0;
case 1:
return 1;
case 2:
case 4:
return 2;
case 3:
case 5:
case 6:
return 3;
case 7:
case 8:
return 4;
default:
throw new IllegalArgumentException("Unsupported task count " + taskCount);
}
}
} }
/** /**