diff options
author | cretin45 <cretin45@gmail.com> | 2016-05-10 13:36:09 -0700 |
---|---|---|
committer | Ed Carrigan <cretin45@gmail.com> | 2016-05-10 14:55:22 -0700 |
commit | 70e60db0360adb5dcd4250c804572c41fa669e9c (patch) | |
tree | 781c001424479b754a3a99cc31368f19d6637016 /src/com/android/launcher3/Utilities.java | |
parent | 019b74b566d0589ada06a3ea6b6b11be829c106a (diff) | |
download | android_packages_apps_Trebuchet-70e60db0360adb5dcd4250c804572c41fa669e9c.tar.gz android_packages_apps_Trebuchet-70e60db0360adb5dcd4250c804572c41fa669e9c.tar.bz2 android_packages_apps_Trebuchet-70e60db0360adb5dcd4250c804572c41fa669e9c.zip |
Trebuchet: Index folder contents screen and cells on first load
Issue-id: CYNGNOS-2755
Change-Id: I260d1b098e7759a0134bc40f892b8783452c9528
(cherry picked from commit 499902463bb16aad036a57b9e02b34cb74548acf)
Diffstat (limited to 'src/com/android/launcher3/Utilities.java')
-rw-r--r-- | src/com/android/launcher3/Utilities.java | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java index bf11aa19e..8ffc471a3 100644 --- a/src/com/android/launcher3/Utilities.java +++ b/src/com/android/launcher3/Utilities.java @@ -39,6 +39,7 @@ import android.graphics.Color; import android.graphics.Matrix; import android.graphics.Paint; import android.graphics.PaintFlagsDrawFilter; +import android.graphics.Point; import android.graphics.Rect; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; @@ -706,6 +707,39 @@ public final class Utilities { size, metrics)); } + public static Point caluclateFolderContentDimensions(int count, int maxCountX, int maxCountY) { + final Point point = new Point(); + final int maxItemsPerPage = maxCountX * maxCountY; + boolean done; + if (count >= maxItemsPerPage) { + point.x = maxCountX; + point.y = maxCountY; + done = true; + } else { + done = false; + } + + while (!done) { + int oldCountX = point.x; + int oldCountY = point.y; + if (point.x * point.y < count) { + // Current grid is too small, expand it + if ((point.x <= point.y || point.y == maxCountY) && point.x < maxCountX) { + point.x++; + } else if (point.y < maxCountY) { + point.y++; + } + if (point.y == 0) point.y++; + } else if ((point.y - 1) * point.x >= count && point.y >= point.x) { + point.y = Math.max(0, point.y - 1); + } else if ((point.x - 1) * point.y >= count) { + point.x = Math.max(0, point.x - 1); + } + done = point.x == oldCountX && point.y == oldCountY; + } + return point; + } + public static String createDbSelectionQuery(String columnName, Iterable<?> values) { return String.format(Locale.ENGLISH, "%s IN (%s)", columnName, TextUtils.join(", ", values)); } |