private void selectShade(int position) {
    ImageView shellSelected;

    for (int i = 0; i < shadeAdapter.getItemCount(); i++) {
      if (recyclerView.getChildAt(i) != null) {
        shellSelected = ((ImageView) recyclerView.getChildAt(i).findViewById(R.id.shell_selected));
        if (shellSelected.getVisibility() == View.VISIBLE) {
          shellSelected.setVisibility(View.GONE);
        }
      }
    }

    GridLayoutManager layoutManager = (GridLayoutManager) recyclerView.getLayoutManager();

    if (getSelectionMode() == SelectionModeEnum.SINGLE_SELECTION_MODE) {

      View view = recyclerView.getChildAt(position - layoutManager.findFirstVisibleItemPosition());

      if (shadeAdapter.getSelectedShade() == position) {
        shadeAdapter.setSelectedShade(-1);

        view.findViewById(R.id.shell_selected).setVisibility(View.INVISIBLE);

      } else {
        shadeAdapter.setSelectedShade(position);

        view.findViewById(R.id.shell_selected).setVisibility(View.VISIBLE);
      }

    } else if (getSelectionMode() == SelectionModeEnum.MULTIPLE_SELECTION_MODE) {

      if (selected.contains(position)) {
        selected.remove((Integer) position);

      } else {
        selected.add(position);
      }

      shadeAdapter.setSelected(selected);

      for (int item : shadeAdapter.getSelected()) {

        if (item >= layoutManager.findFirstVisibleItemPosition()
            && item <= layoutManager.findLastVisibleItemPosition()) {

          View view = recyclerView.getChildAt(item - layoutManager.findFirstVisibleItemPosition());
          view.findViewById(R.id.shell_selected).setVisibility(View.VISIBLE);
        }
      }
    }
  }
  @Override
  public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
    super.onScrolled(recyclerView, dx, dy);
    gridLayoutManager = (GridLayoutManager) recyclerView.getLayoutManager();
    visibleItemCount = recyclerView.getChildCount();
    totalItemCount = gridLayoutManager.getItemCount();
    firstVisibleItem = gridLayoutManager.findFirstVisibleItemPosition();

    if (isVisible && scrollDist > MINIMUM) {
      onHideShow(true);
      scrollDist = 0;
      isVisible = false;
    } else if (!isVisible && scrollDist < -MINIMUM) {
      onHideShow(false);
      scrollDist = 0;
      isVisible = true;
    }
    if ((isVisible && dy > 0) || (!isVisible && dy < 0)) {
      scrollDist += dy;
    }

    if (loading) {
      if (totalItemCount > previousTotal + 1) {
        loading = false;
        previousTotal = totalItemCount;
      }
    }
    if (!loading && (totalItemCount - visibleItemCount) <= (firstVisibleItem + visibleThreshold)) {
      // End has been reached
      // Do something
      current_page++;
      onLoadMore(current_page, totalItemCount);
      loading = true;
    }
  }
 private void changeColumns() {
   int firstVisible = layoutManager.findFirstVisibleItemPosition();
   layoutManager.setSpanCount(columnsCount);
   layoutManager.requestLayout();
   adapter.notifyItemRangeChanged(firstVisible, 0);
 }