summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Adam Powell <adamp@google.com> 2010-03-03 19:50:49 -0800
committer Adam Powell <adamp@google.com> 2010-03-03 19:50:49 -0800
commit0bba68ddc7e489fd6fb1579417a656f77cbc1ab3 (patch)
treed7e298701c3c8dc35d5293814a5aa7fb983cd77f
parent37f700a83cf885447e67053a87d4e30b2f44ae44 (diff)
Fix VelocityTracker for CTS tests
-rw-r--r--core/java/android/view/VelocityTracker.java13
1 files changed, 7 insertions, 6 deletions
diff --git a/core/java/android/view/VelocityTracker.java b/core/java/android/view/VelocityTracker.java
index 91fd6f1a509c..c17a724ff041 100644
--- a/core/java/android/view/VelocityTracker.java
+++ b/core/java/android/view/VelocityTracker.java
@@ -100,6 +100,7 @@ public final class VelocityTracker implements Poolable<VelocityTracker> {
}
private VelocityTracker() {
+ clear();
}
/**
@@ -109,7 +110,7 @@ public final class VelocityTracker implements Poolable<VelocityTracker> {
final long[][] pastTime = mPastTime;
for (int p = 0; p < MotionEvent.BASE_AVAIL_POINTERS; p++) {
for (int i = 0; i < NUM_PAST; i++) {
- pastTime[p][i] = 0;
+ pastTime[p][i] = Long.MIN_VALUE;
}
}
}
@@ -129,7 +130,7 @@ public final class VelocityTracker implements Poolable<VelocityTracker> {
int touchIndex = (mLastTouch + 1) % NUM_PAST;
for (int i=0; i<N; i++) {
for (int id = 0; id < MotionEvent.BASE_AVAIL_POINTERS; id++) {
- mPastTime[id][touchIndex] = 0;
+ mPastTime[id][touchIndex] = Long.MIN_VALUE;
}
for (int p = 0; p < pointerCount; p++) {
int id = ev.getPointerId(p);
@@ -141,10 +142,10 @@ public final class VelocityTracker implements Poolable<VelocityTracker> {
touchIndex = (touchIndex + 1) % NUM_PAST;
}
- // During calculation any pointer values with a time of 0 are treated
- // as a break in input. Initialize all to 0 for each new touch index.
+ // During calculation any pointer values with a time of MIN_VALUE are treated
+ // as a break in input. Initialize all to MIN_VALUE for each new touch index.
for (int id = 0; id < MotionEvent.BASE_AVAIL_POINTERS; id++) {
- mPastTime[id][touchIndex] = 0;
+ mPastTime[id][touchIndex] = Long.MIN_VALUE;
}
final long time = ev.getEventTime();
for (int p = 0; p < pointerCount; p++) {
@@ -189,7 +190,7 @@ public final class VelocityTracker implements Poolable<VelocityTracker> {
// find oldest acceptable time
int oldestTouch = lastTouch;
- if (pastTime[lastTouch] > 0) { // cleared ?
+ if (pastTime[lastTouch] != Long.MIN_VALUE) { // cleared ?
final float acceptableTime = pastTime[lastTouch] - LONGEST_PAST_TIME;
int nextOldestTouch = (NUM_PAST + oldestTouch - 1) % NUM_PAST;
while (pastTime[nextOldestTouch] >= acceptableTime &&