public void onPause() { super.onPause(); if (null != viewPager) { viewPager.stopAutoScroll(); } }
@Override protected void onPause() { super.onPause(); if (viewPager != null) { viewPager.stopAutoScroll(); } }
/** * * * <ul> * if stopScrollWhenTouch is true * <li>if event is down, stop auto scroll. * <li>if event is up, start auto scroll again. * </ul> */ @Override public boolean dispatchTouchEvent(MotionEvent ev) { int action = MotionEventCompat.getActionMasked(ev); if (stopScrollWhenTouch) { if ((action == MotionEvent.ACTION_DOWN) && isAutoScroll) { isStopByTouch = true; stopAutoScroll(); } else if (ev.getAction() == MotionEvent.ACTION_UP && isStopByTouch) { startAutoScroll(); } } if (slideBorderMode == SLIDE_BORDER_MODE_TO_PARENT || slideBorderMode == SLIDE_BORDER_MODE_CYCLE) { touchX = ev.getX(); if (ev.getAction() == MotionEvent.ACTION_DOWN) { downX = touchX; } int currentItem = getCurrentItem(); PagerAdapter adapter = getAdapter(); int pageCount = adapter == null ? 0 : adapter.getCount(); /** * current index is first one and slide to right or current index is last one and slide to * left.<br> * if slide border mode is to parent, then requestDisallowInterceptTouchEvent false.<br> * else scroll to last one when current item is first one, scroll to first one when current * item is last one. */ if ((currentItem == 0 && downX <= touchX) || (currentItem == pageCount - 1 && downX >= touchX)) { if (slideBorderMode == SLIDE_BORDER_MODE_TO_PARENT) { getParent().requestDisallowInterceptTouchEvent(false); } else { if (pageCount > 1) { setCurrentItem(pageCount - currentItem - 1, isBorderAnimation); } getParent().requestDisallowInterceptTouchEvent(true); } return super.dispatchTouchEvent(ev); } } getParent().requestDisallowInterceptTouchEvent(true); return super.dispatchTouchEvent(ev); }