Package 

Class GridLayoutManager.DefaultSpanSizeLookup

    • Method Summary

      Modifier and Type Method Description
      int getSpanSize(int position) Returns the number of span occupied by the item at position.
      int getSpanIndex(int position, int spanCount) Returns the final span index of the provided position.
      • Methods inherited from class tds.androidx.recyclerview.widget.GridLayoutManager.SpanSizeLookup

        getSpanGroupIndex, invalidateSpanGroupIndexCache, invalidateSpanIndexCache, isSpanGroupIndexCacheEnabled, isSpanIndexCacheEnabled, setSpanGroupIndexCacheEnabled, setSpanIndexCacheEnabled
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getSpanSize

         int getSpanSize(int position)

        Returns the number of span occupied by the item at position.

        Parameters:
        position - The adapter position of the item
      • getSpanIndex

         int getSpanIndex(int position, int spanCount)

        Returns the final span index of the provided position.

        If you have a faster way to calculate span index for your items, you should overridethis method. Otherwise, you should enable span index cache(setSpanIndexCacheEnabled) for better performance. When caching isdisabled, default implementation traverses all items from 0 toposition. When caching is enabled, it calculates from the closest cachedvalue before the position.

        If you override this method, you need to make sure it is consistent with getSpanSize. GridLayoutManager does not call this method foreach item. It is called only for the reference item and rest of the itemsare assigned to spans based on the reference item. For example, you cannot assign aposition to span 2 while span 1 is empty.

        Note that span offsets always start with 0 and are not affected by RTL.

        Parameters:
        position - The position of the item
        spanCount - The total number of spans in the grid