summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/Utilities.java
diff options
context:
space:
mode:
authorcretin45 <cretin45@gmail.com>2016-05-10 13:36:09 -0700
committercretin45 <cretin45@gmail.com>2016-05-10 14:48:32 -0700
commit499902463bb16aad036a57b9e02b34cb74548acf (patch)
treec7aff077b09b069f732982b33182443ae98adf6f /src/com/android/launcher3/Utilities.java
parentba9f5508210d6534fa3d8c24679c153be638bf08 (diff)
downloadandroid_packages_apps_Trebuchet-499902463bb16aad036a57b9e02b34cb74548acf.tar.gz
android_packages_apps_Trebuchet-499902463bb16aad036a57b9e02b34cb74548acf.tar.bz2
android_packages_apps_Trebuchet-499902463bb16aad036a57b9e02b34cb74548acf.zip
Trebuchet: Index folder contents screen and cells on first load
Issue-id: CYNGNOS-2755 Change-Id: I260d1b098e7759a0134bc40f892b8783452c9528
Diffstat (limited to 'src/com/android/launcher3/Utilities.java')
-rw-r--r--src/com/android/launcher3/Utilities.java34
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));
}