diff options
author | Sunny Goyal <sunnygoyal@google.com> | 2015-07-06 13:04:02 -0700 |
---|---|---|
committer | Sunny Goyal <sunnygoyal@google.com> | 2015-07-06 13:04:32 -0700 |
commit | 1dd0f8bf51d4e2befe0caece0e361a96ae697f41 (patch) | |
tree | 27fd33d610cfc7c279a807e30d1babb379b05645 | |
parent | bccc43bd8bae92e3e06099a5f4d6a5d5f1ec07df (diff) | |
download | android_packages_apps_Trebuchet-1dd0f8bf51d4e2befe0caece0e361a96ae697f41.tar.gz android_packages_apps_Trebuchet-1dd0f8bf51d4e2befe0caece0e361a96ae697f41.tar.bz2 android_packages_apps_Trebuchet-1dd0f8bf51d4e2befe0caece0e361a96ae697f41.zip |
Using cellX and cellY for comparing position when rank is not available
Bug: 22059402
Change-Id: I69ec2b9b68610e171e76cd968de77aaed669672c
-rw-r--r-- | src/com/android/launcher3/Folder.java | 18 | ||||
-rw-r--r-- | src/com/android/launcher3/Utilities.java | 8 |
2 files changed, 17 insertions, 9 deletions
diff --git a/src/com/android/launcher3/Folder.java b/src/com/android/launcher3/Folder.java index 85f58a1b1..657fb7d9e 100644 --- a/src/com/android/launcher3/Folder.java +++ b/src/com/android/launcher3/Folder.java @@ -61,6 +61,7 @@ import com.android.launcher3.util.Thunk; import java.util.ArrayList; import java.util.Collections; +import java.util.Comparator; /** * Represents a set of icons chosen by the user or generated by the system. @@ -362,7 +363,7 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList void bind(FolderInfo info) { mInfo = info; ArrayList<ShortcutInfo> children = info.contents; - Collections.sort(children, Utilities.RANK_COMPARATOR); + Collections.sort(children, ITEM_POS_COMPARATOR); ArrayList<ShortcutInfo> overflow = mContent.bindItems(children); @@ -1395,4 +1396,19 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList onDragOver(mDragObject, 1); } } + + // Compares item position based on rank and position giving priority to the rank. + private static final Comparator<ItemInfo> ITEM_POS_COMPARATOR = new Comparator<ItemInfo>() { + + @Override + public int compare(ItemInfo lhs, ItemInfo rhs) { + if (lhs.rank != rhs.rank) { + return lhs.rank - rhs.rank; + } else if (lhs.cellY != rhs.cellY) { + return lhs.cellY - rhs.cellY; + } else { + return lhs.cellX - rhs.cellX; + } + } + }; } diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java index 19334ed31..8f4f0f9a1 100644 --- a/src/com/android/launcher3/Utilities.java +++ b/src/com/android/launcher3/Utilities.java @@ -59,7 +59,6 @@ import android.widget.Toast; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.ArrayList; -import java.util.Comparator; import java.util.Locale; import java.util.Set; import java.util.regex.Matcher; @@ -573,13 +572,6 @@ public final class Utilities { } } - public static final Comparator<ItemInfo> RANK_COMPARATOR = new Comparator<ItemInfo>() { - @Override - public int compare(ItemInfo lhs, ItemInfo rhs) { - return lhs.rank - rhs.rank; - } - }; - /** * Find the first vacant cell, if there is one. * |