mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-27 23:36:47 +00:00
Add seam space for performReorder in MultipageCellLayout
In the other method createAreaForResize we add 1 to the cellX to account for the seam in the Multipace CellLayout but we don't account for that on performReorder and we need to add a cellWidth Also, some methods are not running when the seam is added so their result are wrong. Now all methods are being accounted for. Fix: 277709417 Test: atest ReorderAlgorithm Test: atest MulticellReorderAlgorithm Change-Id: I7a4ca55f7b9cd7cf94481c880fe152e0a3bb3cf3
This commit is contained in:
@@ -1269,7 +1269,7 @@ public class CellLayout extends ViewGroup {
|
||||
* @return The X, Y cell of a vacant area that can contain this object,
|
||||
* nearest the requested location.
|
||||
*/
|
||||
private int[] findNearestArea(int relativeXPos, int relativeYPos, int minSpanX, int minSpanY,
|
||||
protected int[] findNearestArea(int relativeXPos, int relativeYPos, int minSpanX, int minSpanY,
|
||||
int spanX, int spanY, boolean ignoreOccupied, int[] result, int[] resultSpan) {
|
||||
// For items with a spanX / spanY > 1, the passed in point (relativeXPos, relativeYPos)
|
||||
// corresponds to the center of the item, but we are searching based on the top-left cell,
|
||||
|
||||
@@ -24,7 +24,6 @@ import android.view.View;
|
||||
|
||||
import com.android.launcher3.celllayout.CellLayoutLayoutParams;
|
||||
import com.android.launcher3.celllayout.MulticellReorderAlgorithm;
|
||||
import com.android.launcher3.celllayout.ReorderAlgorithm;
|
||||
import com.android.launcher3.util.CellAndSpan;
|
||||
import com.android.launcher3.util.GridOccupancy;
|
||||
|
||||
@@ -46,6 +45,33 @@ public class MultipageCellLayout extends CellLayout {
|
||||
this(context, attrs, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int[] findNearestArea(int relativeXPos, int relativeYPos, int minSpanX, int minSpanY,
|
||||
int spanX, int spanY, boolean ignoreOccupied, int[] result, int[] resultSpan) {
|
||||
return createReorderAlgorithm().simulateSeam(
|
||||
() -> super.findNearestArea(relativeXPos, relativeYPos, minSpanX, minSpanY, spanX,
|
||||
spanY, ignoreOccupied, result, resultSpan));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getDirectionVectorForDrop(int dragViewCenterX, int dragViewCenterY, int spanX,
|
||||
int spanY, View dragView, int[] resultDirection) {
|
||||
createReorderAlgorithm().simulateSeam(
|
||||
() -> {
|
||||
super.getDirectionVectorForDrop(dragViewCenterX, dragViewCenterY, spanX, spanY,
|
||||
dragView, resultDirection);
|
||||
return 0;
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNearestDropLocationOccupied(int pixelX, int pixelY, int spanX, int spanY,
|
||||
View dragView, int[] result) {
|
||||
return createReorderAlgorithm().simulateSeam(
|
||||
() -> super.isNearestDropLocationOccupied(pixelX, pixelY, spanX, spanY, dragView,
|
||||
result));
|
||||
}
|
||||
|
||||
public MultipageCellLayout(Context context, AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
mLeftBackground = getContext().getDrawable(R.drawable.bg_celllayout);
|
||||
@@ -71,13 +97,23 @@ public class MultipageCellLayout extends CellLayout {
|
||||
cellX++;
|
||||
}
|
||||
int finalCellX = cellX;
|
||||
return ((MulticellReorderAlgorithm) createReorderAlgorithm()).simulateSeam(
|
||||
return createReorderAlgorithm().simulateSeam(
|
||||
() -> super.createAreaForResize(finalCellX, cellY, spanX, spanY, dragView,
|
||||
direction, commit));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReorderAlgorithm createReorderAlgorithm() {
|
||||
int[] performReorder(int pixelX, int pixelY, int minSpanX, int minSpanY, int spanX, int spanY,
|
||||
View dragView, int[] result, int[] resultSpan, int mode) {
|
||||
if (pixelX >= getWidth() / 2) {
|
||||
pixelX += getCellWidth();
|
||||
}
|
||||
return super.performReorder(pixelX, pixelY, minSpanX, minSpanY, spanX, spanY, dragView,
|
||||
result, resultSpan, mode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MulticellReorderAlgorithm createReorderAlgorithm() {
|
||||
return new MulticellReorderAlgorithm(this);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user