private void recreateLayoutManager() {
        final RecyclerView.LayoutManager currentLm = binding.list.getLayoutManager();
        final int columnCount = model.getColumnCount();
        if (columnCount <= 1) {
            if (!(currentLm instanceof LinearLayoutManager)) {
                binding.list.setLayoutManager(new LinearLayoutManager(getContext()));
            }
        } else {
            if (!(currentLm instanceof GridLayoutManager) || ((GridLayoutManager) currentLm).getSpanCount() != columnCount) {
                binding.list.setLayoutManager(new GridLayoutManager(getContext(), model.getColumnCount()));
            }
            final GridLayoutManager glm = (GridLayoutManager) binding.list.getLayoutManager();
            glm.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
               @Override
               public int getSpanSize(final int pos) {
                   final ListItem item = listAdapter.getItem(pos);
                   if (item.type == ListItemType.ITEM) {
                       final int span = model.getColumnSpanMapper() == null ? 1 : model.getColumnSpanMapper().apply(item.value);
                       return Math.max(1, Math.min(columnCount, span));
                   }
                   return columnCount;
               }
           });
        }
    }
This view displays and maintains a list of simple view items, mainly for (single or multiple)
item selection lists. It provides special support for grouping, filtering and "select all" for such
lists.
main/src/main/java/cgeo/geocaching/ui/SimpleItemListView.java