mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-17 17:48:20 +00:00
Cleanup and refactoring in relation to drag and drop
-> folder creation, adding to folders, reordering, switching pages -> ensuring parity of dragEnter and dragExit in cell layouts and workspace (neither were consistently getting an even number of each) -> actually enforced above with exceptions -- probably want to take these out, but maybe we can leave them in as warnings -> fixed bug with mapping points to hotseat -> fixes other bugs with drag and drop Change-Id: I564568f810f2784d122ec6135012b67c2e8e7551
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.android.launcher2;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.PointF;
|
||||
import android.graphics.Rect;
|
||||
|
||||
@@ -63,6 +64,43 @@ public interface DropTarget {
|
||||
}
|
||||
}
|
||||
|
||||
public static class DragEnforcer implements DragController.DragListener {
|
||||
int dragParity = 0;
|
||||
|
||||
public DragEnforcer(Context context) {
|
||||
Launcher launcher = (Launcher) context;
|
||||
launcher.getDragController().addDragListener(this);
|
||||
}
|
||||
|
||||
void onDragEnter() {
|
||||
dragParity++;
|
||||
if (dragParity != 1) {
|
||||
throw new RuntimeException("onDragEnter: Drag contract violated: " + dragParity);
|
||||
}
|
||||
}
|
||||
|
||||
void onDragExit() {
|
||||
dragParity--;
|
||||
if (dragParity != 0) {
|
||||
throw new RuntimeException("onDragExit: Drag contract violated: " + dragParity);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDragStart(DragSource source, Object info, int dragAction) {
|
||||
if (dragParity != 0) {
|
||||
throw new RuntimeException("onDragEnter: Drag contract violated: " + dragParity);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDragEnd() {
|
||||
if (dragParity != 0) {
|
||||
throw new RuntimeException("onDragExit: Drag contract violated: " + dragParity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to temporarily disable certain drop targets
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user