Cleaning up folder icon drawing

-> Tracking individual drawing parms for each item
-> This enables animation of the preview items as the preview changes

Change-Id: I1b8f650cb28dc09cfb921bbdc93f2a3db61178fd
This commit is contained in:
Adam Cohen
2016-02-13 16:06:05 -08:00
parent 10a0e8a5c6
commit 4f8071b759
5 changed files with 207 additions and 92 deletions

View File

@@ -42,22 +42,28 @@ public class ClippedFolderIconLayoutRule implements FolderIcon.PreviewLayoutRule
public FolderIcon.PreviewItemDrawingParams computePreviewItemDrawingParams(int index,
int curNumItems, FolderIcon.PreviewItemDrawingParams params) {
getPosition(index, curNumItems, mTmpPoint);
float transX = mTmpPoint[0];
float transY = mTmpPoint[1];
float totalScale = scaleForNumItems(curNumItems);
float transX;
float transY;
float overlayAlpha = 0;
// Items beyond those displayed in the preview are animated to the center
if (index >= MAX_NUM_ITEMS_IN_PREVIEW) {
transX = transY = mAvailableSpace / 2 - (mIconSize * totalScale) / 2;
} else {
getPosition(index, curNumItems, mTmpPoint);
transX = mTmpPoint[0];
transY = mTmpPoint[1];
totalScale = scaleForNumItems(curNumItems);
}
if (params == null) {
params = new FolderIcon.PreviewItemDrawingParams(transX, transY, totalScale, overlayAlpha);
} else {
params.transX = transX;
params.transY = transY;
params.scale = totalScale;
params.update(transX, transY, totalScale);
params.overlayAlpha = overlayAlpha;
}
return params;
}
@@ -65,7 +71,6 @@ public class ClippedFolderIconLayoutRule implements FolderIcon.PreviewLayoutRule
// The case of two items is homomorphic to the case of one.
curNumItems = Math.max(curNumItems, 2);
// We model the preview as a circle of items starting in the appropriate piece of the
// upper left quadrant (to achieve horizontal and vertical symmetry).
double theta0 = mIsRtl ? 0 : Math.PI;