summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher2/DropTarget.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/launcher2/DropTarget.java')
-rw-r--r--src/com/android/launcher2/DropTarget.java38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/com/android/launcher2/DropTarget.java b/src/com/android/launcher2/DropTarget.java
index fb714c60a..397d46245 100644
--- a/src/com/android/launcher2/DropTarget.java
+++ b/src/com/android/launcher2/DropTarget.java
@@ -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
*