question: protected void adjustPositionX ( int velocityX ) { if ( reverseLayout ) velocityX *= - 1 ; int childCount = getChildCount ( ) ; if ( childCount > 0 ) { int curPosition = ViewUtils . getCenterXChildPosition ( this ) ; int childWidth = getWidth ( ) - getPaddingLeft ( ) - getPaddingRight ( ) ; int flingCount = getFlingCount ( velocityX , childWidth ) ; int targetPosition = curPosition + flingCount ; if ( mSinglePageFling ) { flingCount = Math . max ( - 1 , Math . min ( 1 , flingCount ) ) ; targetPosition = flingCount == 0 ? curPosition : mPositionOnTouchDown + flingCount ; if ( DEBUG ) { Log . d ( "@" , "flingCount:" + flingCount ) ; Log . d ( "@" , "original targetPosition:" + targetPosition ) ; } } targetPosition = Math . max ( targetPosition , 0 ) ; targetPosition = Math . min ( targetPosition , getItemCount ( ) - 1 ) ; if ( targetPosition == curPosition && ( ! mSinglePageFling || mPositionOnTouchDown == curPosition ) ) { View centerXChild = ViewUtils . getCenterXChild ( this ) ; if ( centerXChild != null ) { if ( mTouchSpan > centerXChild . getWidth ( ) * mTriggerOffset * mTriggerOffset && targetPosition != 0 ) { if ( ! reverseLayout ) targetPosition -- ; else targetPosition ++ ; } else if ( mTouchSpan < centerXChild . getWidth ( ) * - mTriggerOffset && targetPosition != getItemCount ( ) - 1 ) { if ( ! reverseLayout ) targetPosition ++ ; else targetPosition -- ; } } } if ( DEBUG ) { Log . d ( "@" , "mTouchSpan:" + mTouchSpan ) ; Log . d ( "@" , "adjustPositionX:" + targetPosition ) ; } smoothScrollToPosition ( safeTargetPosition ( targetPosition , getItemCount ( ) ) ) ; } }
target:  adjust position before Touch event complete and fling action start.