Closed hadifar closed 7 years ago
Would love a solution to this
After fiddling with the code for a while I was able to fix the issue like the following. This is based on @AmirHadifar 's solution
boolean consumeTouch = false;
if (action == MotionEvent.ACTION_DOWN) {
touchY = ev.getY();
} else if (action == MotionEvent.ACTION_UP) {
consumeTouch = Math.abs(touchY - ev.getY()) > 0;
}
if (consumeTouch) {
getParent().requestDisallowInterceptTouchEvent(true);
} else {
getParent().requestDisallowInterceptTouchEvent(false);
if(stopScrollWhenTouch)
startAutoScroll();
}
@youfacepalm where exactly goes your code? I have the same issue
edit: after testing, there are also issues with this fix. Swiping is a pain now.
Replace dispatchTouchEvent method by this:
@Override public boolean dispatchTouchEvent(MotionEvent ev) { int action = MotionEventCompat.getActionMasked(ev); if (stopWhenTouch) { switch (action) { case MotionEvent.ACTION_DOWN: if (isAutoScroll) { isStopedWhenTouch = true; stopAutoScroll(); } break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_OUTSIDE: if (isStopedWhenTouch) { startAutoScroll(); } break; } } return super.dispatchTouchEvent(ev); }
(sorry for the bad formatting)
@amanzan suggestion worked ..
`@Override public boolean dispatchTouchEvent(MotionEvent ev) { int action = MotionEventCompat.getActionMasked(ev); if (stopWhenTouch) { switch (action) { case MotionEvent.ACTION_DOWN: if (isAutoScroll) { isStopedWhenTouch = true; stopAutoScroll(); } break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_OUTSIDE: if (isStopedWhenTouch) { startAutoScroll(); } break; } } return super.dispatchTouchEvent(ev); }
Hi , first Thanks for your library.
I want to put auto-scroll-view-pager as header of my listview (RecyclerView) but When I scroll up/down it consume touch event. I use following piece of code to handle this issue (I put it in dispatchTouchEvent method ):
It's work somehow but have issue. When I scroll up/down autoScroll mode not worked. Can you help me to solve this issue ?