@Test public void testOnTouchEvent() throws Exception { for(int action:EVENTS) { MotionEvent event = MotionEvent.obtain(100, 100, action, 10, 10, 0); view.onTouchEvent(event); event.recycle(); } }
@Override public boolean onTouchEvent(MotionEvent ev) { if(!scrollable) { return true; } if (mRedirectTouchToStickyView) { if (mScrollRect == null) { mScrollRect = new Rect(); getGlobalVisibleRect(mScrollRect); } mCurrentStickyView.getLocationOnScreen(stickyViewP); ev.offsetLocation(0, -(stickyViewP[1] - mScrollRect.top)); } if (ev.getAction() == MotionEvent.ACTION_DOWN) { mHasNotDoneActionDown = false; } if (mHasNotDoneActionDown) { MotionEvent down = MotionEvent.obtain(ev); down.setAction(MotionEvent.ACTION_DOWN); mHasNotDoneActionDown = false; down.recycle(); } if (ev.getAction() == MotionEvent.ACTION_DOWN) { ox = ev.getX(); oy = ev.getY(); startNestedScroll(ViewCompat.SCROLL_AXIS_HORIZONTAL | ViewCompat.SCROLL_AXIS_VERTICAL); } if (ev.getAction() == MotionEvent.ACTION_UP || ev.getAction() == MotionEvent.ACTION_CANCEL) { mHasNotDoneActionDown = true; stopNestedScroll(); } if (ev.getAction() == MotionEvent.ACTION_MOVE) { float clampedX = ev.getX(); float clampedY = ev.getY(); int dx = (int) (ox - clampedX); int dy = (int) (oy - clampedY); if (dispatchNestedPreScroll(dx, dy, consumed, offsetInWindow)) { ev.setLocation(clampedX+consumed[0],clampedY+consumed[1]); } ox = ev.getX(); oy = ev.getY(); } boolean result = super.onTouchEvent(ev); if (wxGesture != null) { result |= wxGesture.onTouch(this, ev); } return result; }
WXScrollView extends ScrollView implements Callback, IWXScroller,
                                                        WXGestureObservable,NestedScrollingChild { @Override public boolean onTouchEvent(MotionEvent ev) { if(!scrollable) { return true; } if (mRedirectTouchToStickyView) { if (mScrollRect == null) { mScrollRect = new Rect(); getGlobalVisibleRect(mScrollRect); } mCurrentStickyView.getLocationOnScreen(stickyViewP); ev.offsetLocation(0, -(stickyViewP[1] - mScrollRect.top)); } if (ev.getAction() == MotionEvent.ACTION_DOWN) { mHasNotDoneActionDown = false; } if (mHasNotDoneActionDown) { MotionEvent down = MotionEvent.obtain(ev); down.setAction(MotionEvent.ACTION_DOWN); mHasNotDoneActionDown = false; down.recycle(); } if (ev.getAction() == MotionEvent.ACTION_DOWN) { ox = ev.getX(); oy = ev.getY(); startNestedScroll(ViewCompat.SCROLL_AXIS_HORIZONTAL | ViewCompat.SCROLL_AXIS_VERTICAL); } if (ev.getAction() == MotionEvent.ACTION_UP || ev.getAction() == MotionEvent.ACTION_CANCEL) { mHasNotDoneActionDown = true; stopNestedScroll(); } if (ev.getAction() == MotionEvent.ACTION_MOVE) { float clampedX = ev.getX(); float clampedY = ev.getY(); int dx = (int) (ox - clampedX); int dy = (int) (oy - clampedY); if (dispatchNestedPreScroll(dx, dy, consumed, offsetInWindow)) { ev.setLocation(clampedX+consumed[0],clampedY+consumed[1]); } ox = ev.getX(); oy = ev.getY(); } boolean result = super.onTouchEvent(ev); if (wxGesture != null) { result |= wxGesture.onTouch(this, ev); } return result; } }
WXScrollView extends ScrollView implements Callback, IWXScroller,
                                                        WXGestureObservable,NestedScrollingChild { @Override public boolean onTouchEvent(MotionEvent ev) { if(!scrollable) { return true; } if (mRedirectTouchToStickyView) { if (mScrollRect == null) { mScrollRect = new Rect(); getGlobalVisibleRect(mScrollRect); } mCurrentStickyView.getLocationOnScreen(stickyViewP); ev.offsetLocation(0, -(stickyViewP[1] - mScrollRect.top)); } if (ev.getAction() == MotionEvent.ACTION_DOWN) { mHasNotDoneActionDown = false; } if (mHasNotDoneActionDown) { MotionEvent down = MotionEvent.obtain(ev); down.setAction(MotionEvent.ACTION_DOWN); mHasNotDoneActionDown = false; down.recycle(); } if (ev.getAction() == MotionEvent.ACTION_DOWN) { ox = ev.getX(); oy = ev.getY(); startNestedScroll(ViewCompat.SCROLL_AXIS_HORIZONTAL | ViewCompat.SCROLL_AXIS_VERTICAL); } if (ev.getAction() == MotionEvent.ACTION_UP || ev.getAction() == MotionEvent.ACTION_CANCEL) { mHasNotDoneActionDown = true; stopNestedScroll(); } if (ev.getAction() == MotionEvent.ACTION_MOVE) { float clampedX = ev.getX(); float clampedY = ev.getY(); int dx = (int) (ox - clampedX); int dy = (int) (oy - clampedY); if (dispatchNestedPreScroll(dx, dy, consumed, offsetInWindow)) { ev.setLocation(clampedX+consumed[0],clampedY+consumed[1]); } ox = ev.getX(); oy = ev.getY(); } boolean result = super.onTouchEvent(ev); if (wxGesture != null) { result |= wxGesture.onTouch(this, ev); } return result; } WXScrollView(Context context);  WXScrollView(Context context, AttributeSet attrs);  WXScrollView(Context context, AttributeSet attrs, int defStyle); }
WXScrollView extends ScrollView implements Callback, IWXScroller,
                                                        WXGestureObservable,NestedScrollingChild { @Override public boolean onTouchEvent(MotionEvent ev) { if(!scrollable) { return true; } if (mRedirectTouchToStickyView) { if (mScrollRect == null) { mScrollRect = new Rect(); getGlobalVisibleRect(mScrollRect); } mCurrentStickyView.getLocationOnScreen(stickyViewP); ev.offsetLocation(0, -(stickyViewP[1] - mScrollRect.top)); } if (ev.getAction() == MotionEvent.ACTION_DOWN) { mHasNotDoneActionDown = false; } if (mHasNotDoneActionDown) { MotionEvent down = MotionEvent.obtain(ev); down.setAction(MotionEvent.ACTION_DOWN); mHasNotDoneActionDown = false; down.recycle(); } if (ev.getAction() == MotionEvent.ACTION_DOWN) { ox = ev.getX(); oy = ev.getY(); startNestedScroll(ViewCompat.SCROLL_AXIS_HORIZONTAL | ViewCompat.SCROLL_AXIS_VERTICAL); } if (ev.getAction() == MotionEvent.ACTION_UP || ev.getAction() == MotionEvent.ACTION_CANCEL) { mHasNotDoneActionDown = true; stopNestedScroll(); } if (ev.getAction() == MotionEvent.ACTION_MOVE) { float clampedX = ev.getX(); float clampedY = ev.getY(); int dx = (int) (ox - clampedX); int dy = (int) (oy - clampedY); if (dispatchNestedPreScroll(dx, dy, consumed, offsetInWindow)) { ev.setLocation(clampedX+consumed[0],clampedY+consumed[1]); } ox = ev.getX(); oy = ev.getY(); } boolean result = super.onTouchEvent(ev); if (wxGesture != null) { result |= wxGesture.onTouch(this, ev); } return result; } WXScrollView(Context context);  WXScrollView(Context context, AttributeSet attrs);  WXScrollView(Context context, AttributeSet attrs, int defStyle); void startScrollerTask(); void addScrollViewListener(WXScrollViewListener scrollViewListener); void removeScrollViewListener(WXScrollViewListener scrollViewListener); @Override boolean dispatchTouchEvent(MotionEvent ev); @Override boolean onTouchEvent(MotionEvent ev); @Override void setNestedScrollingEnabled(boolean enabled); @Override boolean isNestedScrollingEnabled(); @Override boolean startNestedScroll(int axes); @Override void stopNestedScroll(); @Override boolean hasNestedScrollingParent(); boolean isScrollable(); void setScrollable(boolean scrollable); @Override boolean dispatchNestedScroll(int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed, int[] offsetInWindow); @Override boolean dispatchNestedPreScroll(int dx, int dy, int[] consumed, int[] offsetInWindow); @Override boolean dispatchNestedFling(float velocityX, float velocityY, boolean consumed); @Override boolean dispatchNestedPreFling(float velocityX, float velocityY); @Override boolean onNestedPreFling(View target, float velocityX,
                                  float velocityY); @Override boolean onNestedFling(View target, float velocityX, float velocityY,
                               boolean consumed); @Override void fling(int velocityY); @Override boolean handleMessage(Message msg); @Override void destroy(); @Override void registerGestureListener(WXGesture wxGesture); void setWAScroller(WXScroller mWAScroller); }
WXScrollView extends ScrollView implements Callback, IWXScroller,
                                                        WXGestureObservable,NestedScrollingChild { @Override public boolean onTouchEvent(MotionEvent ev) { if(!scrollable) { return true; } if (mRedirectTouchToStickyView) { if (mScrollRect == null) { mScrollRect = new Rect(); getGlobalVisibleRect(mScrollRect); } mCurrentStickyView.getLocationOnScreen(stickyViewP); ev.offsetLocation(0, -(stickyViewP[1] - mScrollRect.top)); } if (ev.getAction() == MotionEvent.ACTION_DOWN) { mHasNotDoneActionDown = false; } if (mHasNotDoneActionDown) { MotionEvent down = MotionEvent.obtain(ev); down.setAction(MotionEvent.ACTION_DOWN); mHasNotDoneActionDown = false; down.recycle(); } if (ev.getAction() == MotionEvent.ACTION_DOWN) { ox = ev.getX(); oy = ev.getY(); startNestedScroll(ViewCompat.SCROLL_AXIS_HORIZONTAL | ViewCompat.SCROLL_AXIS_VERTICAL); } if (ev.getAction() == MotionEvent.ACTION_UP || ev.getAction() == MotionEvent.ACTION_CANCEL) { mHasNotDoneActionDown = true; stopNestedScroll(); } if (ev.getAction() == MotionEvent.ACTION_MOVE) { float clampedX = ev.getX(); float clampedY = ev.getY(); int dx = (int) (ox - clampedX); int dy = (int) (oy - clampedY); if (dispatchNestedPreScroll(dx, dy, consumed, offsetInWindow)) { ev.setLocation(clampedX+consumed[0],clampedY+consumed[1]); } ox = ev.getX(); oy = ev.getY(); } boolean result = super.onTouchEvent(ev); if (wxGesture != null) { result |= wxGesture.onTouch(this, ev); } return result; } WXScrollView(Context context);  WXScrollView(Context context, AttributeSet attrs);  WXScrollView(Context context, AttributeSet attrs, int defStyle); void startScrollerTask(); void addScrollViewListener(WXScrollViewListener scrollViewListener); void removeScrollViewListener(WXScrollViewListener scrollViewListener); @Override boolean dispatchTouchEvent(MotionEvent ev); @Override boolean onTouchEvent(MotionEvent ev); @Override void setNestedScrollingEnabled(boolean enabled); @Override boolean isNestedScrollingEnabled(); @Override boolean startNestedScroll(int axes); @Override void stopNestedScroll(); @Override boolean hasNestedScrollingParent(); boolean isScrollable(); void setScrollable(boolean scrollable); @Override boolean dispatchNestedScroll(int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed, int[] offsetInWindow); @Override boolean dispatchNestedPreScroll(int dx, int dy, int[] consumed, int[] offsetInWindow); @Override boolean dispatchNestedFling(float velocityX, float velocityY, boolean consumed); @Override boolean dispatchNestedPreFling(float velocityX, float velocityY); @Override boolean onNestedPreFling(View target, float velocityX,
                                  float velocityY); @Override boolean onNestedFling(View target, float velocityX, float velocityY,
                               boolean consumed); @Override void fling(int velocityY); @Override boolean handleMessage(Message msg); @Override void destroy(); @Override void registerGestureListener(WXGesture wxGesture); void setWAScroller(WXScroller mWAScroller);  }