private int determineTargetPage(int currentPage,float pageOffset,int velocity,int deltaX){
  int targetPage;
  if (Math.abs(deltaX) > flingDistance && Math.abs(velocity) > minimumVelocity) {
    if (virtualPos < 0) {
      targetPage=velocity > 0 ? currentPage : currentPage + 1;
    }
 else {
      targetPage=velocity > 0 ? currentPage + 1 : currentPage;
    }
  }
 else {
    final float truncator=currentPage >= currentItem ? 0.4f : 0.6f;
    targetPage=(int)(currentPage + pageOffset + truncator);
  }
  if (items.size() > 0) {
    final ItemInfo firstItem=items.get(0);
    final ItemInfo lastItem=items.get(items.size() - 1);
    targetPage=Math.max(firstItem.position,Math.min(targetPage,lastItem.position));
  }
  if (targetPage > currentPage && onCardChangeListener != null) {
    onCardChangeListener.onCardDismissed(currentPage,virtualPos > 0);
  }
  return targetPage;
}

private int determineTargetPage ( int currentPage , float pageOffset , int velocity , int deltaX ) { int targetPage ; if ( Math . abs ( deltaX ) > flingDistance && Math . abs ( velocity ) > minimumVelocity ) { if ( virtualPos < 0 ) { targetPage = velocity > 0 ? currentPage : currentPage + 1 ; } else { targetPage = velocity > 0 ? currentPage + 1 : currentPage ; } } else { final float truncator = currentPage >= currentItem ? 0.4f : 0.6f ; targetPage = ( int ) ( currentPage + pageOffset + truncator ) ; } if ( items . size ( ) > 0 ) { final ItemInfo firstItem = items . get ( 0 ) ; final ItemInfo lastItem = items . get ( items . size ( ) - 1 ) ; targetPage = Math . max ( firstItem . position , Math . min ( targetPage , lastItem . position ) ) ; } if ( targetPage > currentPage && onCardChangeListener != null ) { onCardChangeListener . onCardDismissed ( currentPage , virtualPos > 0 ) ; } return targetPage ; }
figure out what the target page would be given current scroll and velocity .
