mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-18 10:18:20 +00:00
Update mIsBeingDragged in onTouchEvent(ACTION_DOWN)
The logic to keep mIsBeingDragged when touching down during a scroll animation was in onInterceptTouchEvent(), which we were bypassing by using onTouchEvent() directly. Now we update mIsBeingDragged on touch down in both onInterceptTouchEvent() and in onTouchEvent(). Bug: 141024521 Change-Id: I77abd4c36f3ccee27e160c817dadb3923e6cfc06
This commit is contained in:
@@ -890,23 +890,7 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou
|
||||
mTotalMotionX = 0;
|
||||
mActivePointerId = ev.getPointerId(0);
|
||||
|
||||
/*
|
||||
* If being flinged and user touches the screen, initiate drag;
|
||||
* otherwise don't. mScroller.isFinished should be false when
|
||||
* being flinged.
|
||||
*/
|
||||
final int xDist = Math.abs(mScroller.getFinalPos() - mScroller.getCurrPos());
|
||||
final boolean finishedScrolling = (mScroller.isFinished() || xDist < mTouchSlop / 3);
|
||||
|
||||
if (finishedScrolling) {
|
||||
mIsBeingDragged = false;
|
||||
if (!mScroller.isFinished() && !mFreeScroll) {
|
||||
setCurrentPage(getNextPage());
|
||||
pageEndTransition();
|
||||
}
|
||||
} else {
|
||||
mIsBeingDragged = true;
|
||||
}
|
||||
updateIsBeingDraggedOnTouchDown();
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -929,6 +913,25 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou
|
||||
return mIsBeingDragged;
|
||||
}
|
||||
|
||||
/**
|
||||
* If being flinged and user touches the screen, initiate drag; otherwise don't.
|
||||
*/
|
||||
private void updateIsBeingDraggedOnTouchDown() {
|
||||
// mScroller.isFinished should be false when being flinged.
|
||||
final int xDist = Math.abs(mScroller.getFinalPos() - mScroller.getCurrPos());
|
||||
final boolean finishedScrolling = (mScroller.isFinished() || xDist < mTouchSlop / 3);
|
||||
|
||||
if (finishedScrolling) {
|
||||
mIsBeingDragged = false;
|
||||
if (!mScroller.isFinished() && !mFreeScroll) {
|
||||
setCurrentPage(getNextPage());
|
||||
pageEndTransition();
|
||||
}
|
||||
} else {
|
||||
mIsBeingDragged = true;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isHandlingTouch() {
|
||||
return mIsBeingDragged;
|
||||
}
|
||||
@@ -1104,6 +1107,8 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou
|
||||
|
||||
switch (action & MotionEvent.ACTION_MASK) {
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
updateIsBeingDraggedOnTouchDown();
|
||||
|
||||
/*
|
||||
* If being flinged and user touches, stop the fling. isFinished
|
||||
* will be false if being flinged.
|
||||
|
||||
Reference in New Issue
Block a user