diff options
| author | 2012-10-07 21:12:03 -0700 | |
|---|---|---|
| committer | 2012-10-07 21:12:04 -0700 | |
| commit | de8e3b122bbbd61aa35fd5cd4fe2fc86cd6f0040 (patch) | |
| tree | 027c47c1bbb9f61fce0c912250ab0640044ed84f | |
| parent | 33a8bd8c40ac3c19674043b1cf3e232a3220868f (diff) | |
| parent | 9d09824a66e3a9785f3f05929bc9139da108efe4 (diff) | |
Merge "Fix NPE if pulling down QS quickly on very first boot." into jb-mr1-dev
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java | 39 |
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; |