private Span getNextSpan ( int defaultLine , LayoutStateWrapper layoutState , LayoutManagerHelper helper ) { OrientationHelperEx orientationHelper = helper . getMainOrientationHelper ( ) ; boolean preferLastSpan = false ; if ( helper . getOrientation ( ) == HORIZONTAL ) { preferLastSpan = ( layoutState . getLayoutDirection ( ) == LAYOUT_START ) != helper . getReverseLayout ( ) ; } else { preferLastSpan = ( ( layoutState . getLayoutDirection ( ) == LAYOUT_START ) == helper . getReverseLayout ( ) ) == helper . isDoLayoutRTL ( ) ; } final int startIndex , endIndex , diff ; if ( preferLastSpan ) { startIndex = mNumLanes - 1 ; endIndex = - 1 ; diff = - 1 ; } else { startIndex = 0 ; endIndex = mNumLanes ; diff = 1 ; } if ( layoutState . getLayoutDirection ( ) == LAYOUT_END ) { Span min = null ; int minLine = Integer . MAX_VALUE ; for ( int i = startIndex ; i != endIndex ; i += diff ) { final Span other = mSpans [ i ] ; int otherLine = other . getEndLine ( defaultLine , orientationHelper ) ; if ( BuildConfig . DEBUG ) { Log . d ( TAG , "end starIndex " + i + " end otherLine " + otherLine ) ; } if ( otherLine < minLine ) { min = other ; minLine = otherLine ; } if ( BuildConfig . DEBUG ) { Log . d ( TAG , "end min " + min + " end minLine " + minLine ) ; } } if ( BuildConfig . DEBUG ) { Log . d ( TAG , "final end min " + min + " final end minLine " + minLine ) ; } return min ; } else { Span max = null ; int maxLine = Integer . MIN_VALUE ; for ( int i = startIndex ; i != endIndex ; i += diff ) { final Span other = mSpans [ i ] ; int otherLine = other . getStartLine ( defaultLine , orientationHelper ) ; if ( BuildConfig . DEBUG ) { Log . d ( TAG , "start starIndex " + i + " start otherLine " + otherLine ) ; } if ( otherLine > maxLine ) { max = other ; maxLine = otherLine ; } if ( BuildConfig . DEBUG ) { Log . d ( TAG , "start max " + max + " start maxLine " + maxLine ) ; } } if ( BuildConfig . DEBUG ) { Log . d ( TAG , "final start max " + max + " final start maxLine " + maxLine ) ; } return max ; } }
Finds the span for the next view .