am 322b0a16: Merge "Protecting more views from (bad) MotionEvents"

* commit '322b0a160d29ddbac35d59655111c8730cadd3e2':
  Protecting more views from (bad) MotionEvents
This commit is contained in:
Jean-Baptiste Queru
2012-08-23 15:09:35 -07:00
committed by Android Git Automerger
2 changed files with 27 additions and 0 deletions

View File

@@ -22,6 +22,7 @@ import android.graphics.Canvas;
import android.graphics.Rect;
import android.os.Bundle;
import android.util.AttributeSet;
import android.util.Log;
import android.view.FocusFinder;
import android.view.InputDevice;
import android.view.KeyEvent;
@@ -62,6 +63,7 @@ public class HorizontalScrollView extends FrameLayout {
private static final float MAX_SCROLL_FACTOR = ScrollView.MAX_SCROLL_FACTOR;
private static final String TAG = "HorizontalScrollView";
private long mLastScroll;
@@ -456,6 +458,12 @@ public class HorizontalScrollView extends FrameLayout {
}
final int pointerIndex = ev.findPointerIndex(activePointerId);
if (pointerIndex == -1) {
Log.e(TAG, "Invalid pointerId=" + activePointerId
+ " in onInterceptTouchEvent");
break;
}
final int x = (int) ev.getX(pointerIndex);
final int xDiff = (int) Math.abs(x - mLastMotionX);
if (xDiff > mTouchSlop) {
@@ -557,6 +565,11 @@ public class HorizontalScrollView extends FrameLayout {
}
case MotionEvent.ACTION_MOVE:
final int activePointerIndex = ev.findPointerIndex(mActivePointerId);
if (activePointerIndex == -1) {
Log.e(TAG, "Invalid pointerId=" + mActivePointerId + " in onTouchEvent");
break;
}
final int x = (int) ev.getX(activePointerIndex);
int deltaX = mLastMotionX - x;
if (!mIsBeingDragged && Math.abs(deltaX) > mTouchSlop) {

View File

@@ -25,6 +25,7 @@ import android.graphics.Rect;
import android.os.Bundle;
import android.os.StrictMode;
import android.util.AttributeSet;
import android.util.Log;
import android.view.FocusFinder;
import android.view.InputDevice;
import android.view.KeyEvent;
@@ -69,6 +70,8 @@ public class ScrollView extends FrameLayout {
static final float MAX_SCROLL_FACTOR = 0.5f;
private static final String TAG = "ScrollView";
private long mLastScroll;
private final Rect mTempRect = new Rect();
@@ -478,6 +481,12 @@ public class ScrollView extends FrameLayout {
}
final int pointerIndex = ev.findPointerIndex(activePointerId);
if (pointerIndex == -1) {
Log.e(TAG, "Invalid pointerId=" + activePointerId
+ " in onInterceptTouchEvent");
break;
}
final int y = (int) ev.getY(pointerIndex);
final int yDiff = Math.abs(y - mLastMotionY);
if (yDiff > mTouchSlop) {
@@ -585,6 +594,11 @@ public class ScrollView extends FrameLayout {
}
case MotionEvent.ACTION_MOVE:
final int activePointerIndex = ev.findPointerIndex(mActivePointerId);
if (activePointerIndex == -1) {
Log.e(TAG, "Invalid pointerId=" + mActivePointerId + " in onTouchEvent");
break;
}
final int y = (int) ev.getY(activePointerIndex);
int deltaY = mLastMotionY - y;
if (!mIsBeingDragged && Math.abs(deltaY) > mTouchSlop) {