@Override
 public void onLayoutChildren(RecyclerView.Recycler recycler, RecyclerView.State state) {
   if (mColumnWidthChanged && mColumnWidth > 0) {
     int totalSpace;
     if (getOrientation() == VERTICAL) {
       totalSpace = getWidth() - getPaddingRight() - getPaddingLeft();
     } else {
       totalSpace = getHeight() - getPaddingTop() - getPaddingBottom();
     }
     int spanCount = Math.max(1, totalSpace / mColumnWidth);
     setSpanCount(spanCount);
     mColumnWidthChanged = false;
   }
   super.onLayoutChildren(recycler, state);
 }
 @Override
 public void onLayoutChildren(RecyclerView.Recycler recycler, RecyclerView.State state) {
   updateSpanCount();
   super.onLayoutChildren(recycler, state);
 }
 @Override
 public void onLayoutChildren(RecyclerView.Recycler recycler, RecyclerView.State state) {
   super.onLayoutChildren(recycler, state);
 }