Adding scroll disambiguation between Workspace and AppWidgets

Change-Id: Ia3ff92b74651f9ea250664ec4cbcc0506db522ec
This commit is contained in:
Adam Cohen committed 2011-02-01 21:47:33 -08:00
1 parent bfadaad352
commit f8d2823d88
2 files changed
+60 -13

No files matched your search

+20 -12
View File
@@ -825,11 +825,15 @@ public abstract class PagedView extends ViewGroup {
anim.start();
}
protected void determineScrollingStart(MotionEvent ev) {
determineScrollingStart(ev, 1.0f);
}
/*
* Determines if we should change the touch state to start scrolling after the
* user moves their touch point too far.
*/
protected void determineScrollingStart(MotionEvent ev) {
protected void determineScrollingStart(MotionEvent ev, float touchSlopScale) {
/*
* Locally do absolute value. mLastMotionX is set to the y value
* of the down event.
@@ -840,12 +844,12 @@ public abstract class PagedView extends ViewGroup {
final int xDiff = (int) Math.abs(x - mLastMotionX);
final int yDiff = (int) Math.abs(y - mLastMotionY);
final int touchSlop = mTouchSlop;
final int touchSlop = Math.round(touchSlopScale * mTouchSlop);
boolean xPaged = xDiff > mPagingTouchSlop;
boolean xMoved = xDiff > touchSlop;
boolean yMoved = yDiff > touchSlop;
if (xMoved || yMoved) {
if (xMoved || xPaged || yMoved) {
if (mUsePagingTouchSlop ? xPaged : xMoved) {
// Scroll if the user moved far enough along the X axis
mTouchState = TOUCH_STATE_SCROLLING;
@@ -855,15 +859,19 @@ public abstract class PagedView extends ViewGroup {
pageBeginMoving();
}
// Either way, cancel any pending longpress
if (mAllowLongPress) {
mAllowLongPress = false;
// Try canceling the long press. It could also have been scheduled
// by a distant descendant, so use the mAllowLongPress flag to block
// everything
final View currentPage = getPageAt(mCurrentPage);
if (currentPage != null) {
currentPage.cancelLongPress();
}
cancelCurrentPageLongPress();
}
}
protected void cancelCurrentPageLongPress() {
if (mAllowLongPress) {
mAllowLongPress = false;
// Try canceling the long press. It could also have been scheduled
// by a distant descendant, so use the mAllowLongPress flag to block
// everything
final View currentPage = getPageAt(mCurrentPage);
if (currentPage != null) {
currentPage.cancelLongPress();
}
}
}