[Arakhnę-Dev] [433] * Fixing the gesture recognizers for the zoomable view on Android OS. |
[ Thread Index |
Date Index
| More arakhne.org/dev Archives
]
Revision: 433
Author: galland
Date: 2013-04-27 15:01:04 +0200 (Sat, 27 Apr 2013)
Log Message:
-----------
* Fixing the gesture recognizers for the zoomable view on Android OS.
Modified Paths:
--------------
trunk/ui/ui-android/src/main/java/org/arakhne/afc/ui/android/zoom/ZoomableView.java
Modified: trunk/ui/ui-android/src/main/java/org/arakhne/afc/ui/android/zoom/ZoomableView.java
===================================================================
--- trunk/ui/ui-android/src/main/java/org/arakhne/afc/ui/android/zoom/ZoomableView.java 2013-04-27 13:00:25 UTC (rev 432)
+++ trunk/ui/ui-android/src/main/java/org/arakhne/afc/ui/android/zoom/ZoomableView.java 2013-04-27 13:01:04 UTC (rev 433)
@@ -863,7 +863,9 @@
}
// Let the inherited function inspect all events for click and long click events.
- if (!this.scaleGestureDetector.isInProgress() && super.onTouchEvent(ev)) {
+ if (!this.scaleGestureDetector.isInProgress()
+ && !this.moveGestureDetector.isInProgress()
+ && super.onTouchEvent(ev)) {
consumed = true;
}
@@ -1015,7 +1017,8 @@
boolean b = false;
this.isClickEnabled = false;
if (isLongClickable()
- && !ZoomableView.this.scaleGestureDetector.isInProgress()) {
+ && !ZoomableView.this.scaleGestureDetector.isInProgress()
+ && !ZoomableView.this.moveGestureDetector.isInProgress()) {
if (this.onLongClickListener!=null) {
b = this.onLongClickListener.onLongClick(v);
}
@@ -1036,7 +1039,8 @@
@Override
public void onClick(View v) {
if (isClickable()
- && !ZoomableView.this.scaleGestureDetector.isInProgress()) {
+ && !ZoomableView.this.scaleGestureDetector.isInProgress()
+ && !ZoomableView.this.moveGestureDetector.isInProgress()) {
if (this.isClickEnabled) {
if (this.onClickListener!=null) {
this.onClickListener.onClick(v);
@@ -1070,8 +1074,13 @@
*/
private float lastTouchY = Float.NaN;
- /** Indicates if the move gesture is in progress.
+ /** Indicates if the move gesture is activated (by a touch down for example).
*/
+ private boolean isActivated = false;
+
+ /** Indicates if the move gesture is in progress, ie.
+ * touch down and move events were found.
+ */
private boolean inProgress = false;
/** Identifier of the current active pointer.
@@ -1085,6 +1094,15 @@
public MoveGestureDetector() {
//
}
+
+ /** Replies if a move gesture is in progress.
+ *
+ * @return <code>true</code> if a move gesture is in progress;
+ * otherwise <code>false</code>.
+ */
+ public boolean isInProgress() {
+ return this.inProgress;
+ }
/** Invoked for detecting touch gestures.
*
@@ -1132,7 +1150,8 @@
}
consumed = this.lastPointerEvent.isConsumed();
if (!consumed) {
- this.inProgress = true;
+ this.isActivated = true;
+ this.inProgress = false;
this.activePointerId = ev.getPointerId(0);
this.lastTouchX = ev.getX(0);
this.lastTouchY = ev.getY(0);
@@ -1143,7 +1162,9 @@
break;
case MotionEvent.ACTION_MOVE:
- if (this.inProgress) {
+ if (this.isActivated) {
+ this.inProgress = true;
+
pointerIndex = ev.findPointerIndex(this.activePointerId);
x = ev.getX(pointerIndex);
y = ev.getY(pointerIndex);
@@ -1175,7 +1196,8 @@
case MotionEvent.ACTION_UP:
this.lastTouchX = ev.getX();
this.lastTouchY = ev.getY();
- if (this.inProgress) {
+ if (this.isActivated) {
+ this.isActivated = false;
this.inProgress = false;
this.activePointerId = INVALID_POINTER_ID;
repaint();
@@ -1193,7 +1215,8 @@
case MotionEvent.ACTION_CANCEL:
this.lastTouchX = ev.getX();
this.lastTouchY = ev.getY();
- if (this.inProgress) {
+ if (this.isActivated) {
+ this.isActivated = false;
this.inProgress = false;
this.activePointerId = INVALID_POINTER_ID;
repaint();
@@ -1209,7 +1232,7 @@
break;
case MotionEvent.ACTION_POINTER_UP:
- if (this.inProgress) {
+ if (this.isActivated) {
pointerIndex = ((ev.getAction() & MotionEvent.ACTION_POINTER_INDEX_MASK) >> MotionEvent.ACTION_POINTER_INDEX_SHIFT);
pointerId = ev.getPointerId(pointerIndex);
if (pointerId == this.activePointerId) {