summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/Folder.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/launcher3/Folder.java')
-rw-r--r--src/com/android/launcher3/Folder.java18
1 files changed, 17 insertions, 1 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;
+ }
+ }
+ };
}