package biz.kasual.recyclerfragmentsample.fragments;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.GridLayoutManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import java.util.Collections;
import java.util.Comparator;
import java.util.List;

import biz.kasual.recyclerfragmentsample.adapters.SampleAdapter;
import biz.kasual.recyclerfragmentsample.models.Sample;

/**
 * Created by Stephen Vinouze on 06/11/2015.
 */
public class SectionRecyclerFragment extends AbstractRecyclerFragment {

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View contentView = super.onCreateView(inflater, container, savedInstanceState);

        configureFragment(mRecyclerView, mSampleAdapter);

        GridLayoutManager manager = new GridLayoutManager(getActivity(), 5);
        setLayoutManager(manager);

        List<Sample> samples = SampleAdapter.buildSamples();

        Collections.sort(samples, new Comparator<Sample>() {
            @Override
            public int compare(Sample lhs, Sample rhs) {
                return lhs.getRate() - rhs.getRate();
            }
        });

        displayItems(samples);

        return contentView;
    }

    @Override
    public String sortSectionMethod() {
        return "getRate";
    }
}

@@ -882,16 +882,77 @@
         
+// Set grid layout manager to display data as grid%0A        /*
 GridLayo
@@ -1008,17 +1008,17 @@
 vity(), 
-5
+3
 );%0A     
@@ -1042,24 +1042,26 @@
 er(manager);
+*/
 %0A%0A        Li

Disable grid in demo