am adb93889: Merge "Delay starting scale gesture events until a touch slop threshold" into jb-mr1-dev
* commit 'adb93889ae013cee70c8c50622aa17e2e44c2ba8': Delay starting scale gesture events until a touch slop threshold
This commit is contained in:
@@ -86,8 +86,8 @@ public class ScaleGestureDetector {
|
|||||||
* pointers going up.
|
* pointers going up.
|
||||||
*
|
*
|
||||||
* Once a scale has ended, {@link ScaleGestureDetector#getFocusX()}
|
* Once a scale has ended, {@link ScaleGestureDetector#getFocusX()}
|
||||||
* and {@link ScaleGestureDetector#getFocusY()} will return the location
|
* and {@link ScaleGestureDetector#getFocusY()} will return focal point
|
||||||
* of the pointer remaining on the screen.
|
* of the pointers remaining on the screen.
|
||||||
*
|
*
|
||||||
* @param detector The detector reporting the event - use this to
|
* @param detector The detector reporting the event - use this to
|
||||||
* retrieve extended info about event state.
|
* retrieve extended info about event state.
|
||||||
@@ -128,6 +128,7 @@ public class ScaleGestureDetector {
|
|||||||
|
|
||||||
private float mCurrSpan;
|
private float mCurrSpan;
|
||||||
private float mPrevSpan;
|
private float mPrevSpan;
|
||||||
|
private float mInitialSpan;
|
||||||
private float mCurrSpanX;
|
private float mCurrSpanX;
|
||||||
private float mCurrSpanY;
|
private float mCurrSpanY;
|
||||||
private float mPrevSpanX;
|
private float mPrevSpanX;
|
||||||
@@ -135,6 +136,7 @@ public class ScaleGestureDetector {
|
|||||||
private long mCurrTime;
|
private long mCurrTime;
|
||||||
private long mPrevTime;
|
private long mPrevTime;
|
||||||
private boolean mInProgress;
|
private boolean mInProgress;
|
||||||
|
private int mSpanSlop;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Consistency verifier for debugging purposes.
|
* Consistency verifier for debugging purposes.
|
||||||
@@ -146,6 +148,7 @@ public class ScaleGestureDetector {
|
|||||||
public ScaleGestureDetector(Context context, OnScaleGestureListener listener) {
|
public ScaleGestureDetector(Context context, OnScaleGestureListener listener) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mListener = listener;
|
mListener = listener;
|
||||||
|
mSpanSlop = ViewConfiguration.get(context).getScaledTouchSlop() * 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -176,6 +179,7 @@ public class ScaleGestureDetector {
|
|||||||
if (mInProgress) {
|
if (mInProgress) {
|
||||||
mListener.onScaleEnd(this);
|
mListener.onScaleEnd(this);
|
||||||
mInProgress = false;
|
mInProgress = false;
|
||||||
|
mInitialSpan = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (streamComplete) {
|
if (streamComplete) {
|
||||||
@@ -221,18 +225,24 @@ public class ScaleGestureDetector {
|
|||||||
// Dispatch begin/end events as needed.
|
// Dispatch begin/end events as needed.
|
||||||
// If the configuration changes, notify the app to reset its current state by beginning
|
// If the configuration changes, notify the app to reset its current state by beginning
|
||||||
// a fresh scale event stream.
|
// a fresh scale event stream.
|
||||||
|
final boolean wasInProgress = mInProgress;
|
||||||
|
mFocusX = focusX;
|
||||||
|
mFocusY = focusY;
|
||||||
if (mInProgress && (span == 0 || configChanged)) {
|
if (mInProgress && (span == 0 || configChanged)) {
|
||||||
mListener.onScaleEnd(this);
|
mListener.onScaleEnd(this);
|
||||||
mInProgress = false;
|
mInProgress = false;
|
||||||
|
mInitialSpan = span;
|
||||||
}
|
}
|
||||||
if (configChanged) {
|
if (configChanged) {
|
||||||
mPrevSpanX = mCurrSpanX = spanX;
|
mPrevSpanX = mCurrSpanX = spanX;
|
||||||
mPrevSpanY = mCurrSpanY = spanY;
|
mPrevSpanY = mCurrSpanY = spanY;
|
||||||
mPrevSpan = mCurrSpan = span;
|
mInitialSpan = mPrevSpan = mCurrSpan = span;
|
||||||
}
|
}
|
||||||
if (!mInProgress && span != 0) {
|
if (!mInProgress && span != 0 &&
|
||||||
mFocusX = focusX;
|
(wasInProgress || Math.abs(span - mInitialSpan) > mSpanSlop)) {
|
||||||
mFocusY = focusY;
|
mPrevSpanX = mCurrSpanX = spanX;
|
||||||
|
mPrevSpanY = mCurrSpanY = spanY;
|
||||||
|
mPrevSpan = mCurrSpan = span;
|
||||||
mInProgress = mListener.onScaleBegin(this);
|
mInProgress = mListener.onScaleBegin(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -241,8 +251,6 @@ public class ScaleGestureDetector {
|
|||||||
mCurrSpanX = spanX;
|
mCurrSpanX = spanX;
|
||||||
mCurrSpanY = spanY;
|
mCurrSpanY = spanY;
|
||||||
mCurrSpan = span;
|
mCurrSpan = span;
|
||||||
mFocusX = focusX;
|
|
||||||
mFocusY = focusY;
|
|
||||||
|
|
||||||
boolean updatePrev = true;
|
boolean updatePrev = true;
|
||||||
if (mInProgress) {
|
if (mInProgress) {
|
||||||
|
|||||||
Reference in New Issue
Block a user