<commit_before>package ca.antonious.sample;

import android.os.Bundle;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.LinearLayoutManager;
import android.view.Menu;
import android.view.MenuItem;

import java.util.Arrays;
import java.util.Locale;

import ca.antonious.sample.models.SampleModel;
import ca.antonious.sample.viewcells.EmptyViewCell;
import ca.antonious.sample.viewcells.SampleModelViewCell;
import ca.antonious.viewcelladapter.ViewCellAdapter;
import ca.antonious.viewcelladapter.construction.SectionBuilder;
import ca.antonious.viewcelladapter.extensions.ViewCellGridLayoutManager;
import ca.antonious.viewcelladapter.sections.HomogeneousSection;
import ca.antonious.viewcelladapter.viewcells.AbstractViewCell;
import ca.antonious.viewcelladapter.viewcells.builtins.MaterialLabelViewCell;

/**
 * Created by George on 2017-05-14.
 */

public class GridLayoutSample extends BaseActivity {
    private ViewCellAdapter viewCellAdapter;
    private HomogeneousSection<SampleModel, SampleModelViewCell> section1;
    private HomogeneousSection<SampleModel, SampleModelViewCell> section2;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        viewCellAdapter = buildAdapter();

        recyclerView.setAdapter(viewCellAdapter);
        recyclerView.setLayoutManager(ViewCellGridLayoutManager.create(this, viewCellAdapter, 4));
    }

    private ViewCellAdapter buildAdapter() {
        // create sections
        section1 = new HomogeneousSection<>(SampleModel.class, SampleModelViewCell.class);
        section2 = new HomogeneousSection<>(SampleModel.class, SampleModelViewCell.class);

        return ViewCellAdapter.create()
                .section(
                    SectionBuilder.createCompositeSection()
                        .section(
                            SectionBuilder.wrap(section1)
                                    .header(buildHeader("Section 1"))
                                    .hideHeaderIfEmpty()
                                    .build()
                        )
                        .section(
                            SectionBuilder.wrap(section2)
                                    .header(buildHeader("Section 2"))
                                    .hideHeaderIfEmpty()
                                    .build()
                        )
                        .showIfEmpty(new EmptyViewCell("Add items at the top"))
                        .build()
                )
                .listener(new SampleModelViewCell.OnSampleModelClickListener() {
                    @Override
                    public void onSampleModelClick(SampleModel sampleModel) {
                        String snackMessage = String.format(Locale.getDefault(), "%s was clicked!", sampleModel.getName());
                        showSnackbar(snackMessage);<commit_msg>Use span count of 3 in grid sample<commit_after>package ca.antonious.sample;

import android.os.Bundle;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.LinearLayoutManager;
import android.view.Menu;
import android.view.MenuItem;

import java.util.Arrays;
import java.util.Locale;

import ca.antonious.sample.models.SampleModel;
import ca.antonious.sample.viewcells.EmptyViewCell;
import ca.antonious.sample.viewcells.SampleModelViewCell;
import ca.antonious.viewcelladapter.ViewCellAdapter;
import ca.antonious.viewcelladapter.construction.SectionBuilder;
import ca.antonious.viewcelladapter.extensions.ViewCellGridLayoutManager;
import ca.antonious.viewcelladapter.sections.HomogeneousSection;
import ca.antonious.viewcelladapter.viewcells.AbstractViewCell;
import ca.antonious.viewcelladapter.viewcells.builtins.MaterialLabelViewCell;

/**
 * Created by George on 2017-05-14.
 */

public class GridLayoutSample extends BaseActivity {
    private ViewCellAdapter viewCellAdapter;
    private HomogeneousSection<SampleModel, SampleModelViewCell> section1;
    private HomogeneousSection<SampleModel, SampleModelViewCell> section2;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        viewCellAdapter = buildAdapter();

        recyclerView.setAdapter(viewCellAdapter);
        recyclerView.setLayoutManager(ViewCellGridLayoutManager.create(this, viewCellAdapter, 3));
    }
 
    private ViewCellAdapter buildAdapter() {
        // create sections
        section1 = new HomogeneousSection<>(SampleModel.class, SampleModelViewCell.class);
        section2 = new HomogeneousSection<>(SampleModel.class, SampleModelViewCell.class);

        return ViewCellAdapter.create()
                .section(
                    SectionBuilder.createCompositeSection()
                        .section(
                            SectionBuilder.wrap(section1)
                                    .header(buildHeader("Section 1"))
                                    .hideHeaderIfEmpty()
                                    .build()
                        )
                        .section(
                            SectionBuilder.wrap(section2)
                                    .header(buildHeader("Section 2"))
                                    .hideHeaderIfEmpty()
                                    .build()
                        )
                        .showIfEmpty(new EmptyViewCell("Add items at the top"))
                        .build()
                )
                .listener(new SampleModelViewCell.OnSampleModelClickListener() {
                    @Override
                    public void onSampleModelClick(SampleModel sampleModel) {
                        String snackMessage = String.format(Locale.getDefault(), "%s was clicked!", sampleModel.getName());
                        showSnackbar(snackMessage);
{'fraction_non_alphanumeric': 0.07892039631021523, 'fraction_numerical': 0.006662111376836351, 'mean_word_length': 2.23302043070127, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '418186', 'n_tokens_mistral': 1426, 'n_tokens_neox': 1347, 'n_words': 242}