Code example for ViewPager

Methods: , onInterceptTouchEvent

0
 
    @Override 
    public boolean onInterceptTouchEvent(MotionEvent event) {
        if ((event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_UP)
        { 
            super.onInterceptTouchEvent(event);
        } 
 
        float [] difference = handleMotionEvent(event);
 
        if (mCurrentView.pagerCanScroll()) {
            return super.onInterceptTouchEvent(event);
        } 
        else { 
            if (difference != null && mCurrentView.onRightSide && difference[0] < 0) //move right
            { 
                return super.onInterceptTouchEvent(event);
            } 
            if (difference != null && mCurrentView.onLeftSide && difference[0] > 0) //move left
            { 
                return super.onInterceptTouchEvent(event);
            } 
            if (difference == null && ( mCurrentView.onLeftSide || mCurrentView.onRightSide))
            { 
                return super.onInterceptTouchEvent(event);
            } 
        } 
        return false; 
    } 
}