Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7b9173b6 authored by Daniel Sandler's avatar Daniel Sandler Committed by Android Git Automerger
Browse files

am a53d38bc: Merge "Drop simultaneous pointer events when tracking velocity." into klp-dev

* commit 'a53d38bc':
  Drop simultaneous pointer events when tracking velocity.
parents 217f37ce a53d38bc
Loading
Loading
Loading
Loading
+16 −7
Original line number Original line Diff line number Diff line
@@ -118,7 +118,7 @@ public class PanelView extends FrameLayout {
            int i = 0;
            int i = 0;
            float totalweight = 0f;
            float totalweight = 0f;
            float weight = 10f;
            float weight = 10f;
            for (final Iterator<MotionEventCopy> iter = mEventBuf.descendingIterator();
            for (final Iterator<MotionEventCopy> iter = mEventBuf.iterator();
                    iter.hasNext();) {
                    iter.hasNext();) {
                final MotionEventCopy event = iter.next();
                final MotionEventCopy event = iter.next();
                if (last != null) {
                if (last != null) {
@@ -126,13 +126,22 @@ public class PanelView extends FrameLayout {
                    final float dx = (event.x - last.x);
                    final float dx = (event.x - last.x);
                    final float dy = (event.y - last.y);
                    final float dy = (event.y - last.y);
                    if (FlingTracker.DEBUG) {
                    if (FlingTracker.DEBUG) {
                        Log.v("FlingTracker", String.format("   [%d] dx=%.1f dy=%.1f dt=%.0f vx=%.1f vy=%.1f",
                        Log.v("FlingTracker", String.format(
                                i,
                                "   [%d] (t=%d %.1f,%.1f) dx=%.1f dy=%.1f dt=%f vx=%.1f vy=%.1f",
                                i, event.t, event.x, event.y,
                                dx, dy, dt,
                                dx, dy, dt,
                                (dx/dt),
                                (dx/dt),
                                (dy/dt)
                                (dy/dt)
                                ));
                                ));
                    }
                    }
                    if (event.t == last.t) {
                        // Really not sure what to do with events that happened at the same time,
                        // so we'll skip subsequent events.
                        if (DEBUG_NAN) {
                            Log.v("FlingTracker", "skipping simultaneous event at t=" + event.t);
                        }
                        continue;
                    }
                    mVX += weight * dx / dt;
                    mVX += weight * dx / dt;
                    mVY += weight * dy / dt;
                    mVY += weight * dy / dt;
                    totalweight += weight;
                    totalweight += weight;
@@ -158,18 +167,18 @@ public class PanelView extends FrameLayout {
            }
            }
        }
        }
        public float getXVelocity() {
        public float getXVelocity() {
            if (Float.isNaN(mVX)) {
            if (Float.isNaN(mVX) || Float.isInfinite(mVX)) {
                if (DEBUG_NAN) {
                if (DEBUG_NAN) {
                    Log.v("FlingTracker", "warning: vx=NaN");
                    Log.v("FlingTracker", "warning: vx=" + mVX);
                }
                }
                mVX = 0;
                mVX = 0;
            }
            }
            return mVX;
            return mVX;
        }
        }
        public float getYVelocity() {
        public float getYVelocity() {
            if (Float.isNaN(mVY)) {
            if (Float.isNaN(mVY) || Float.isInfinite(mVX)) {
                if (DEBUG_NAN) {
                if (DEBUG_NAN) {
                    Log.v("FlingTracker", "warning: vx=NaN");
                    Log.v("FlingTracker", "warning: vx=" + mVY);
                }
                }
                mVY = 0;
                mVY = 0;
            }
            }