Added FolderIconPreviewVerifier class.

This class verifies whether an item in a Foder is displayed in
the FolderIcon preview, based on the item's rank.

We use this class to determine which items in a Folder will be
displayed in the preview.

Bug: 35064148
Change-Id: Ia21bccbd95c348efeac62591ae3696a4c60b5339
This commit is contained in:
Jon Miranda
2017-02-07 11:40:22 -08:00
parent ea61fb24a6
commit 655ec42ce5
6 changed files with 139 additions and 58 deletions

View File

@@ -129,24 +129,4 @@ public class ClippedFolderIconLayoutRule implements FolderIcon.PreviewLayoutRule
public boolean clipToBackground() {
return true;
}
@Override
public List<View> getItemsToDisplay(Folder folder) {
List<View> items = new ArrayList<>(folder.getItemsInReadingOrder());
int numItems = items.size();
if (FeatureFlags.LAUNCHER3_NEW_FOLDER_ANIMATION && numItems > MAX_NUM_ITEMS_IN_PREVIEW) {
// We match the icons in the preview with the layout of the opened folder (b/27944225),
// but we still need to figure out how we want to handle updating the preview when the
// upper left quadrant changes.
int appsPerRow = folder.mContent.getPageAt(0).getCountX();
int appsToDelete = appsPerRow - MAX_NUM_ITEMS_PER_ROW;
// We only display the upper left quadrant.
while (appsToDelete > 0) {
items.remove(MAX_NUM_ITEMS_PER_ROW);
appsToDelete--;
}
}
return items.subList(0, Math.min(numItems, MAX_NUM_ITEMS_IN_PREVIEW));
}
}