Merge "Using cellX and cellY for comparing position when rank is not available" into ub-launcher3-burnaby
This commit is contained in:
@@ -62,6 +62,7 @@ import com.android.launcher3.util.UiThreadCircularReveal;
|
||||
|
||||
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.
|
||||
@@ -363,7 +364,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);
|
||||
|
||||
@@ -1396,4 +1397,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;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user