summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java39
1 files changed, 23 insertions, 16 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
index 0c9683d15387..b3cf85435a86 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
@@ -281,22 +281,32 @@ public class PanelView extends FrameLayout {
mHandleView.setPressed(false);
mBar.onTrackingStopped(PanelView.this);
trackMovement(event);
- mVelocityTracker.computeCurrentVelocity(1000);
- float yVel = mVelocityTracker.getYVelocity();
- boolean negative = yVel < 0;
+ float vel = 0, yVel = 0, xVel = 0;
+ boolean negative = false;
- float xVel = mVelocityTracker.getXVelocity();
- if (xVel < 0) {
- xVel = -xVel;
- }
- if (xVel > mFlingGestureMaxXVelocityPx) {
- xVel = mFlingGestureMaxXVelocityPx; // limit how much we care about the x axis
- }
+ if (mVelocityTracker != null) {
+ // the velocitytracker might be null if we got a bad input stream
+ mVelocityTracker.computeCurrentVelocity(1000);
+
+ yVel = mVelocityTracker.getYVelocity();
+ negative = yVel < 0;
- float vel = (float)Math.hypot(yVel, xVel);
- if (vel > mFlingGestureMaxOutputVelocityPx) {
- vel = mFlingGestureMaxOutputVelocityPx;
+ xVel = mVelocityTracker.getXVelocity();
+ if (xVel < 0) {
+ xVel = -xVel;
+ }
+ if (xVel > mFlingGestureMaxXVelocityPx) {
+ xVel = mFlingGestureMaxXVelocityPx; // limit how much we care about the x axis
+ }
+
+ vel = (float)Math.hypot(yVel, xVel);
+ if (vel > mFlingGestureMaxOutputVelocityPx) {
+ vel = mFlingGestureMaxOutputVelocityPx;
+ }
+
+ mVelocityTracker.recycle();
+ mVelocityTracker = null;
}
// if you've barely moved your finger, we treat the velocity as 0
@@ -321,9 +331,6 @@ public class PanelView extends FrameLayout {
fling(vel, true);
- mVelocityTracker.recycle();
- mVelocityTracker = null;
-
break;
}
return true;