* commit '9f44ea8fbcee80816f4ce6eeca2568ccd06d5a15': Improve fling physics for recents
This commit is contained in:
@@ -50,7 +50,6 @@ public class SwipeHelper {
|
|||||||
private float SWIPE_ESCAPE_VELOCITY = 100f; // dp/sec
|
private float SWIPE_ESCAPE_VELOCITY = 100f; // dp/sec
|
||||||
private int DEFAULT_ESCAPE_ANIMATION_DURATION = 75; // ms
|
private int DEFAULT_ESCAPE_ANIMATION_DURATION = 75; // ms
|
||||||
private int MAX_ESCAPE_ANIMATION_DURATION = 150; // ms
|
private int MAX_ESCAPE_ANIMATION_DURATION = 150; // ms
|
||||||
private int MAX_DISMISS_VELOCITY = 2000; // dp/sec
|
|
||||||
private static final int SNAP_ANIM_LEN = SLOW_ANIMATIONS ? 1000 : 250; // ms
|
private static final int SNAP_ANIM_LEN = SLOW_ANIMATIONS ? 1000 : 250; // ms
|
||||||
|
|
||||||
public static float ALPHA_FADE_START = 0.15f; // fraction of thumbnail width
|
public static float ALPHA_FADE_START = 0.15f; // fraction of thumbnail width
|
||||||
@@ -350,8 +349,7 @@ public class SwipeHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void endSwipe(VelocityTracker velocityTracker) {
|
private void endSwipe(VelocityTracker velocityTracker) {
|
||||||
float maxVelocity = MAX_DISMISS_VELOCITY * mDensityScale;
|
velocityTracker.computeCurrentVelocity(1000 /* px/sec */);
|
||||||
velocityTracker.computeCurrentVelocity(1000 /* px/sec */, maxVelocity);
|
|
||||||
float velocity = getVelocity(velocityTracker);
|
float velocity = getVelocity(velocityTracker);
|
||||||
float perpendicularVelocity = getPerpendicularVelocity(velocityTracker);
|
float perpendicularVelocity = getPerpendicularVelocity(velocityTracker);
|
||||||
float escapeVelocity = SWIPE_ESCAPE_VELOCITY * mDensityScale;
|
float escapeVelocity = SWIPE_ESCAPE_VELOCITY * mDensityScale;
|
||||||
|
|||||||
@@ -143,22 +143,21 @@ class TaskStackViewTouchHandler implements SwipeHelper.Callback {
|
|||||||
// Initialize the velocity tracker
|
// Initialize the velocity tracker
|
||||||
initOrResetVelocityTracker();
|
initOrResetVelocityTracker();
|
||||||
mVelocityTracker.addMovement(createMotionEventForStackScroll(ev));
|
mVelocityTracker.addMovement(createMotionEventForStackScroll(ev));
|
||||||
// Check if the scroller is finished yet
|
|
||||||
mIsScrolling = mScroller.isScrolling();
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MotionEvent.ACTION_MOVE: {
|
case MotionEvent.ACTION_MOVE: {
|
||||||
if (mActivePointerId == INACTIVE_POINTER_ID) break;
|
if (mActivePointerId == INACTIVE_POINTER_ID) break;
|
||||||
|
|
||||||
|
// Initialize the velocity tracker if necessary
|
||||||
|
initVelocityTrackerIfNotExists();
|
||||||
|
mVelocityTracker.addMovement(createMotionEventForStackScroll(ev));
|
||||||
|
|
||||||
int activePointerIndex = ev.findPointerIndex(mActivePointerId);
|
int activePointerIndex = ev.findPointerIndex(mActivePointerId);
|
||||||
int y = (int) ev.getY(activePointerIndex);
|
int y = (int) ev.getY(activePointerIndex);
|
||||||
int x = (int) ev.getX(activePointerIndex);
|
int x = (int) ev.getX(activePointerIndex);
|
||||||
if (Math.abs(y - mInitialMotionY) > mScrollTouchSlop) {
|
if (Math.abs(y - mInitialMotionY) > mScrollTouchSlop) {
|
||||||
// Save the touch move info
|
// Save the touch move info
|
||||||
mIsScrolling = true;
|
mIsScrolling = true;
|
||||||
// Initialize the velocity tracker if necessary
|
|
||||||
initVelocityTrackerIfNotExists();
|
|
||||||
mVelocityTracker.addMovement(createMotionEventForStackScroll(ev));
|
|
||||||
// Disallow parents from intercepting touch events
|
// Disallow parents from intercepting touch events
|
||||||
final ViewParent parent = mSv.getParent();
|
final ViewParent parent = mSv.getParent();
|
||||||
if (parent != null) {
|
if (parent != null) {
|
||||||
@@ -237,6 +236,8 @@ class TaskStackViewTouchHandler implements SwipeHelper.Callback {
|
|||||||
case MotionEvent.ACTION_MOVE: {
|
case MotionEvent.ACTION_MOVE: {
|
||||||
if (mActivePointerId == INACTIVE_POINTER_ID) break;
|
if (mActivePointerId == INACTIVE_POINTER_ID) break;
|
||||||
|
|
||||||
|
mVelocityTracker.addMovement(createMotionEventForStackScroll(ev));
|
||||||
|
|
||||||
int activePointerIndex = ev.findPointerIndex(mActivePointerId);
|
int activePointerIndex = ev.findPointerIndex(mActivePointerId);
|
||||||
int x = (int) ev.getX(activePointerIndex);
|
int x = (int) ev.getX(activePointerIndex);
|
||||||
int y = (int) ev.getY(activePointerIndex);
|
int y = (int) ev.getY(activePointerIndex);
|
||||||
@@ -246,9 +247,6 @@ class TaskStackViewTouchHandler implements SwipeHelper.Callback {
|
|||||||
if (!mIsScrolling) {
|
if (!mIsScrolling) {
|
||||||
if (yTotal > mScrollTouchSlop) {
|
if (yTotal > mScrollTouchSlop) {
|
||||||
mIsScrolling = true;
|
mIsScrolling = true;
|
||||||
// Initialize the velocity tracker
|
|
||||||
initOrResetVelocityTracker();
|
|
||||||
mVelocityTracker.addMovement(createMotionEventForStackScroll(ev));
|
|
||||||
// Disallow parents from intercepting touch events
|
// Disallow parents from intercepting touch events
|
||||||
final ViewParent parent = mSv.getParent();
|
final ViewParent parent = mSv.getParent();
|
||||||
if (parent != null) {
|
if (parent != null) {
|
||||||
@@ -267,11 +265,6 @@ class TaskStackViewTouchHandler implements SwipeHelper.Callback {
|
|||||||
/ maxOverScroll));
|
/ maxOverScroll));
|
||||||
}
|
}
|
||||||
mScroller.setStackScroll(curStackScroll + deltaP);
|
mScroller.setStackScroll(curStackScroll + deltaP);
|
||||||
if (mScroller.isScrollOutOfBounds()) {
|
|
||||||
mVelocityTracker.clear();
|
|
||||||
} else {
|
|
||||||
mVelocityTracker.addMovement(createMotionEventForStackScroll(ev));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
mLastMotionX = x;
|
mLastMotionX = x;
|
||||||
mLastMotionY = y;
|
mLastMotionY = y;
|
||||||
|
|||||||
Reference in New Issue
Block a user