summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorRomain Guy <romainguy@android.com>2009-06-02 21:56:27 -0700
committerRomain Guy <romainguy@android.com>2009-06-02 21:59:42 -0700
commit9af0b4f7be14f2b3ed0ecc843c57ea47ec288e55 (patch)
treeb3adeb84b7b5a8ab420cf178db107f19edb2ad78 /core
parent97c2fdfc2e1cb4f51c624dd8e30e6bdb63ea21be (diff)
downloadframeworks_base-9af0b4f7be14f2b3ed0ecc843c57ea47ec288e55.zip
frameworks_base-9af0b4f7be14f2b3ed0ecc843c57ea47ec288e55.tar.gz
frameworks_base-9af0b4f7be14f2b3ed0ecc843c57ea47ec288e55.tar.bz2
Add new listener to GestureOverlayView. This listener fires whenever the overlay thinks the user is starting a new gesture. This allows Home to snap the workspace back to its original position during a gesture operation.
Diffstat (limited to 'core')
-rwxr-xr-xcore/java/android/gesture/GestureOverlayView.java47
1 files changed, 42 insertions, 5 deletions
diff --git a/core/java/android/gesture/GestureOverlayView.java b/core/java/android/gesture/GestureOverlayView.java
index 227cf3d..6f2c2a7 100755
--- a/core/java/android/gesture/GestureOverlayView.java
+++ b/core/java/android/gesture/GestureOverlayView.java
@@ -106,6 +106,9 @@ public class GestureOverlayView extends FrameLayout {
// TODO: Make this a list of WeakReferences
private final ArrayList<OnGesturePerformedListener> mOnGesturePerformedListeners =
new ArrayList<OnGesturePerformedListener>();
+ // TODO: Make this a list of WeakReferences
+ private final ArrayList<OnGesturingListener> mOnGesturingListeners =
+ new ArrayList<OnGesturingListener>();
private boolean mHandleGestureActions;
@@ -319,6 +322,18 @@ public class GestureOverlayView extends FrameLayout {
mHandleGestureActions = false;
}
+ public void addOnGesturingListener(OnGesturingListener listener) {
+ mOnGesturingListeners.add(listener);
+ }
+
+ public void removeOnGesturingListener(OnGesturingListener listener) {
+ mOnGesturingListeners.remove(listener);
+ }
+
+ public void removeAllOnGesturingListeners() {
+ mOnGesturingListeners.clear();
+ }
+
public boolean isGesturing() {
return mIsGesturing;
}
@@ -401,7 +416,7 @@ public class GestureOverlayView extends FrameLayout {
MotionEvent.ACTION_CANCEL, 0.0f, 0.0f, 0);
final ArrayList<OnGestureListener> listeners = mOnGestureListeners;
- final int count = listeners.size();
+ int count = listeners.size();
for (int i = 0; i < count; i++) {
listeners.get(i).onGestureCancelled(this, event);
}
@@ -411,6 +426,12 @@ public class GestureOverlayView extends FrameLayout {
clear(false);
mIsGesturing = false;
mStrokeBuffer.clear();
+
+ final ArrayList<OnGesturingListener> otherListeners = mOnGesturingListeners;
+ count = otherListeners.size();
+ for (int i = 0; i < count; i++) {
+ otherListeners.get(i).onGesturingEnded(this);
+ }
}
@Override
@@ -577,6 +598,12 @@ public class GestureOverlayView extends FrameLayout {
mIsGesturing = true;
setCurrentColor(mCertainGestureColor);
+
+ final ArrayList<OnGesturingListener> listeners = mOnGesturingListeners;
+ int count = listeners.size();
+ for (int i = 0; i < count; i++) {
+ listeners.get(i).onGesturingStarted(this);
+ }
}
}
}
@@ -621,6 +648,12 @@ public class GestureOverlayView extends FrameLayout {
mStrokeBuffer.clear();
mIsGesturing = false;
+
+ final ArrayList<OnGesturingListener> listeners = mOnGesturingListeners;
+ int count = listeners.size();
+ for (int i = 0; i < count; i++) {
+ listeners.get(i).onGesturingEnded(this);
+ }
}
private void cancelGesture(MotionEvent event) {
@@ -635,12 +668,10 @@ public class GestureOverlayView extends FrameLayout {
}
private void fireOnGesturePerformed() {
- final ArrayList<OnGesturePerformedListener> actionListeners =
- mOnGesturePerformedListeners;
+ final ArrayList<OnGesturePerformedListener> actionListeners = mOnGesturePerformedListeners;
final int count = actionListeners.size();
for (int i = 0; i < count; i++) {
- actionListeners.get(i).onGesturePerformed(GestureOverlayView.this,
- mCurrentGesture);
+ actionListeners.get(i).onGesturePerformed(GestureOverlayView.this, mCurrentGesture);
}
}
@@ -683,6 +714,12 @@ public class GestureOverlayView extends FrameLayout {
}
}
+ public static interface OnGesturingListener {
+ void onGesturingStarted(GestureOverlayView overlay);
+
+ void onGesturingEnded(GestureOverlayView overlay);
+ }
+
public static interface OnGestureListener {
void onGestureStarted(GestureOverlayView overlay, MotionEvent event);