| Chunk |
|---|
| Conflicting content |
|---|
final float mPastY[][] = new float[MotionEvent.BASE_AVAIL_POINTERS][NUM_PAST];
final long mPastTime[][] = new long[MotionEvent.BASE_AVAIL_POINTERS][NUM_PAST];
<<<<<<< HEAD
float mYVelocity[] = new float[MotionEvent.BASE_AVAIL_POINTERS];
float mXVelocity[] = new float[MotionEvent.BASE_AVAIL_POINTERS];
=======
int mLastTouch;
float mYVelocity;
float mXVelocity;
>>>>>>> b09ef7b4fa388c1399a6359e239789ca0137aaac
private VelocityTracker mNext;
|
| Solution content |
|---|
final float mPastY[][] = new float[MotionEvent.BASE_AVAIL_POINTERS][NUM_PAST];
final long mPastTime[][] = new long[MotionEvent.BASE_AVAIL_POINTERS][NUM_PAST];
float mYVelocity[] = new float[MotionEvent.BASE_AVAIL_POINTERS];
float mXVelocity[] = new float[MotionEvent.BASE_AVAIL_POINTERS];
int mLastTouch;
private VelocityTracker mNext;
|
| File |
|---|
| VelocityTracker.java |
| Developer's decision |
|---|
| Combination |
| Kind of conflict |
|---|
| Attribute |
| Method invocation |
| Chunk |
|---|
| Conflicting content |
|---|
* Reset the velocity tracker back to its initial state.
*/
public void clear() {
<<<<<<< HEAD
for (int i = 0; i < MotionEvent.BASE_AVAIL_POINTERS; i++) {
mPastTime[i][0] = 0;
=======
final long[] pastTime = mPastTime;
for (int i = 0; i < NUM_PAST; i++) {
pastTime[i] = 0;
>>>>>>> b09ef7b4fa388c1399a6359e239789ca0137aaac
}
}
|
| Solution content |
|---|
* Reset the velocity tracker back to its initial state.
*/
public void clear() {
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;
}
}
}
|
| File |
|---|
| VelocityTracker.java |
| Developer's decision |
|---|
| Manual |
| Kind of conflict |
|---|
| Array access |
| Attribute |
| For statement |
| Variable |
| Chunk |
|---|
| Conflicting content |
|---|
}
}
<<<<<<< HEAD
private void addPoint(int pos, float x, float y, long time) {
int drop = -1;
int i;
if (localLOGV) Log.v(TAG, "Adding past y=" + y + " time=" + time);
final long[] pastTime = mPastTime[pos];
for (i=0; i |
| Solution content |
|---|
}
}
private void addPoint(int pos, float x, float y, long time) {
final int lastTouch = (mLastTouch + 1) % NUM_PAST;
mPastX[pos][lastTouch] = x;
mPastY[pos][lastTouch] = y;
mPastTime[pos][lastTouch] = time;
mLastTouch = lastTouch;
}
/** |
| File |
|---|
| VelocityTracker.java |
| Developer's decision |
|---|
| Manual |
| Kind of conflict |
|---|
| Array access |
| Attribute |
| For statement |
| If statement |
| Method signature |
| Variable |
| Chunk |
|---|
| Conflicting content |
|---|
* must be positive.
*/
public void computeCurrentVelocity(int units, float maxVelocity) {
<<<<<<< HEAD
for (int pos = 0; pos < MotionEvent.BASE_AVAIL_POINTERS; pos++) {
final float[] pastX = mPastX[pos];
final float[] pastY = mPastY[pos];
final long[] pastTime = mPastTime[pos];
// Kind-of stupid.
final float oldestX = pastX[0];
final float oldestY = pastY[0];
final long oldestTime = pastTime[0];
float accumX = 0;
float accumY = 0;
int N=0;
while (N < NUM_PAST) {
if (pastTime[N] == 0) {
break;
}
N++;
}
// Skip the last received event, since it is probably pretty noisy.
if (N > 3) N--;
for (int i=1; i < N; i++) {
final int dur = (int)(pastTime[i] - oldestTime);
if (dur == 0) continue;
float dist = pastX[i] - oldestX;
float vel = (dist/dur) * units; // pixels/frame.
if (accumX == 0) accumX = vel;
else accumX = (accumX + vel) * .5f;
dist = pastY[i] - oldestY;
vel = (dist/dur) * units; // pixels/frame.
if (accumY == 0) accumY = vel;
else accumY = (accumY + vel) * .5f;
}
mXVelocity[pos] = accumX < 0.0f ? Math.max(accumX, -maxVelocity)
: Math.min(accumX, maxVelocity);
mYVelocity[pos] = accumY < 0.0f ? Math.max(accumY, -maxVelocity)
: Math.min(accumY, maxVelocity);
if (localLOGV) Log.v(TAG, "Y velocity=" + mYVelocity +" X velocity="
+ mXVelocity + " N=" + N);
=======
final float[] pastX = mPastX;
final float[] pastY = mPastY;
final long[] pastTime = mPastTime;
final int lastTouch = mLastTouch;
// find oldest acceptable time
int oldestTouch = lastTouch;
if (pastTime[lastTouch] > 0) { // cleared ?
oldestTouch = (lastTouch + 1) % NUM_PAST;
final float acceptableTime = pastTime[lastTouch] - LONGEST_PAST_TIME;
while (pastTime[oldestTouch] < acceptableTime) {
oldestTouch = (oldestTouch + 1) % NUM_PAST;
}
}
// Kind-of stupid.
final float oldestX = pastX[oldestTouch];
final float oldestY = pastY[oldestTouch];
final long oldestTime = pastTime[oldestTouch];
float accumX = 0;
float accumY = 0;
float N = (lastTouch - oldestTouch + NUM_PAST) % NUM_PAST + 1;
// Skip the last received event, since it is probably pretty noisy.
if (N > 3) N--;
for (int i=1; i < N; i++) {
final int j = (oldestTouch + i) % NUM_PAST;
final int dur = (int)(pastTime[j] - oldestTime);
if (dur == 0) continue;
float dist = pastX[j] - oldestX;
float vel = (dist/dur) * units; // pixels/frame.
accumX = (accumX == 0) ? vel : (accumX + vel) * .5f;
dist = pastY[j] - oldestY;
vel = (dist/dur) * units; // pixels/frame.
accumY = (accumY == 0) ? vel : (accumY + vel) * .5f;
>>>>>>> b09ef7b4fa388c1399a6359e239789ca0137aaac
}
}
|
| Solution content |
|---|
* must be positive.
*/
public void computeCurrentVelocity(int units, float maxVelocity) {
for (int pos = 0; pos < MotionEvent.BASE_AVAIL_POINTERS; pos++) {
final float[] pastX = mPastX[pos];
final float[] pastY = mPastY[pos];
final long[] pastTime = mPastTime[pos];
final int lastTouch = mLastTouch;
// find oldest acceptable time
int oldestTouch = lastTouch;
if (pastTime[lastTouch] > 0) { // cleared ?
oldestTouch = (lastTouch + 1) % NUM_PAST;
final float acceptableTime = pastTime[lastTouch] - LONGEST_PAST_TIME;
while (pastTime[oldestTouch] < acceptableTime) {
oldestTouch = (oldestTouch + 1) % NUM_PAST;
}
}
// Kind-of stupid.
final float oldestX = pastX[oldestTouch];
final float oldestY = pastY[oldestTouch];
final long oldestTime = pastTime[oldestTouch];
float accumX = 0;
float accumY = 0;
float N = (lastTouch - oldestTouch + NUM_PAST) % NUM_PAST + 1;
// Skip the last received event, since it is probably pretty noisy.
if (N > 3) N--;
for (int i=1; i < N; i++) {
final int j = (oldestTouch + i) % NUM_PAST;
final int dur = (int)(pastTime[j] - oldestTime);
if (dur == 0) continue;
float dist = pastX[j] - oldestX;
float vel = (dist/dur) * units; // pixels/frame.
accumX = (accumX == 0) ? vel : (accumX + vel) * .5f;
dist = pastY[j] - oldestY;
vel = (dist/dur) * units; // pixels/frame.
accumY = (accumY == 0) ? vel : (accumY + vel) * .5f;
}
mXVelocity[pos] = accumX < 0.0f ? Math.max(accumX, -maxVelocity)
: Math.min(accumX, maxVelocity);
mYVelocity[pos] = accumY < 0.0f ? Math.max(accumY, -maxVelocity)
: Math.min(accumY, maxVelocity);
if (localLOGV) Log.v(TAG, "Y velocity=" + mYVelocity +" X velocity="
+ mXVelocity + " N=" + N);
}
}
|
| File |
|---|
| VelocityTracker.java |
| Developer's decision |
|---|
| Combination |
| Kind of conflict |
|---|
| Array access |
| Attribute |
| Cast expression |
| Comment |
| For statement |
| If statement |
| Method invocation |
| Variable |
| While statement |