From 70e60db0360adb5dcd4250c804572c41fa669e9c Mon Sep 17 00:00:00 2001 From: cretin45 Date: Tue, 10 May 2016 13:36:09 -0700 Subject: Trebuchet: Index folder contents screen and cells on first load Issue-id: CYNGNOS-2755 Change-Id: I260d1b098e7759a0134bc40f892b8783452c9528 (cherry picked from commit 499902463bb16aad036a57b9e02b34cb74548acf) --- src/com/android/launcher3/FolderPagedView.java | 32 ++++---------------------- 1 file changed, 4 insertions(+), 28 deletions(-) (limited to 'src/com/android/launcher3/FolderPagedView.java') diff --git a/src/com/android/launcher3/FolderPagedView.java b/src/com/android/launcher3/FolderPagedView.java index 5d5ac3d5a..9134dc93e 100644 --- a/src/com/android/launcher3/FolderPagedView.java +++ b/src/com/android/launcher3/FolderPagedView.java @@ -18,6 +18,7 @@ package com.android.launcher3; import android.annotation.SuppressLint; import android.content.Context; +import android.graphics.Point; import android.util.AttributeSet; import android.util.Log; import android.view.Gravity; @@ -116,34 +117,9 @@ public class FolderPagedView extends PagedView { */ public void setupContentDimensions(int count) { mAllocatedContentSize = count; - boolean done; - if (count >= mMaxItemsPerPage) { - mGridCountX = mMaxCountX; - mGridCountY = mMaxCountY; - done = true; - } else { - done = false; - } - - while (!done) { - int oldCountX = mGridCountX; - int oldCountY = mGridCountY; - if (mGridCountX * mGridCountY < count) { - // Current grid is too small, expand it - if ((mGridCountX <= mGridCountY || mGridCountY == mMaxCountY) && mGridCountX < mMaxCountX) { - mGridCountX++; - } else if (mGridCountY < mMaxCountY) { - mGridCountY++; - } - if (mGridCountY == 0) mGridCountY++; - } else if ((mGridCountY - 1) * mGridCountX >= count && mGridCountY >= mGridCountX) { - mGridCountY = Math.max(0, mGridCountY - 1); - } else if ((mGridCountX - 1) * mGridCountY >= count) { - mGridCountX = Math.max(0, mGridCountX - 1); - } - done = mGridCountX == oldCountX && mGridCountY == oldCountY; - } - + Point point = Utilities.caluclateFolderContentDimensions(count, mMaxCountX, mMaxCountY); + mGridCountX = point.x; + mGridCountY = point.y; // Update grid size for (int i = getPageCount() - 1; i >= 0; i--) { getPageAt(i).setGridSize(mGridCountX, mGridCountY); -- cgit v1.2.3