private int getNumberOfColumns() {
    int numberOfColumns = 1;

    if (layoutManager instanceof GridLayoutManager) {
      GridLayoutManager gridLayoutManager = (GridLayoutManager) layoutManager;
      numberOfColumns = gridLayoutManager.getSpanCount();
    }

    return numberOfColumns;
  }
Returns the position adjacent to the provided one in a specific direction.
dividers/src/main/java/com/karumi/dividers/PositionAdapter.java