private boolean itemIsObscuredByHeader ( RecyclerView parent , View item , View header , int orientation ) { RecyclerView . LayoutParams layoutParams = ( RecyclerView . LayoutParams ) item . getLayoutParams ( ) ; mDimensionCalculator . initMargins ( mTempRect1 , header ) ; int adapterPosition = parent . getChildAdapterPosition ( item ) ; if ( adapterPosition == RecyclerView . NO_POSITION || mHeaderProvider . getHeader ( parent , adapterPosition ) != header ) { // Resolves https://github.com/timehop/sticky-headers-recyclerview/issues/36 // Handles an edge case where a trailing header is smaller than the current sticky header. return false ; } if ( orientation == LinearLayoutManager . VERTICAL ) { int itemTop = item . getTop ( ) - layoutParams . topMargin ; int headerBottom = getListTop ( parent ) + header . getBottom ( ) + mTempRect1 . bottom + mTempRect1 . top ; if ( itemTop >= headerBottom ) { return false ; } } else { int itemLeft = item . getLeft ( ) - layoutParams . leftMargin ; int headerRight = getListLeft ( parent ) + header . getRight ( ) + mTempRect1 . right + mTempRect1 . left ; if ( itemLeft >= headerRight ) { return false ; } } return true ; }
Determines if an item is obscured by a header