<commit_before>package com.jamieadkins.commonutils.ui;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.ViewGroup;

import com.jamieadkins.commonutils.R;

import java.util.ArrayList;
import java.util.List;

/**
 * Holds base logic for recycler view adapters.
 */

public abstract class BaseRecyclerViewAdapter
        extends RecyclerView.Adapter<BaseViewHolder> {
    private List<RecyclerViewItem> mItems;

    public RecyclerViewItem getItemAt(int position) {
        return mItems.get(position);
    }

    public BaseRecyclerViewAdapter() {
        mItems = new ArrayList<>();
    }

    @Override
    public int getItemCount() {
        if (mItems == null) {
            return 0;
        } else {
            return mItems.size();
        }
    }

    @Override
    public int getItemViewType(int position) {
        return mItems.get(position).getItemType();
    }

    @Override
    public BaseViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        switch (viewType) {
            case Header.TYPE_HEADER:
                return new HeaderViewHolder(LayoutInflater.from(parent.getContext())
                        .inflate(R.layout.item_header, parent, false));
            case SubHeader.TYPE_SUB_HEADER:
                return new SubHeaderViewHolder(LayoutInflater.from(parent.getContext())
                        .inflate(R.layout.item_subheader, parent, false));
            case GoogleNowSubHeader.TYPE_GOOGLE_NOW_SUB_HEADER:
                return new GoogleNowSubHeaderViewHolder(LayoutInflater.from(parent.getContext())
                        .inflate(R.layout.item_google_subheader, parent, false));
            default:
                throw new RuntimeException("Detail level has not been implemented.");
        }
    }

    @Override
    public void onBindViewHolder(BaseViewHolder holder, int position) {
        holder.bindItem(mItems.get(position));
    }

    public void addItem(RecyclerViewItem item) {
        if (!mItems.contains(item)) {
            mItems.add(item);
            notifyDataSetChanged();
        }
    }

    public void addItem(int position, RecyclerViewItem item) {
        if (!mItems.contains(item)) {
            mItems.add(position, item);
            notifyDataSetChanged();
        }
    }

    public void removeItem(RecyclerViewItem itemToRemove) {
        mItems.remove(itemToRemove);
        notifyDataSetChanged();
    }

    public void clear() {
        mItems.clear();
        notifyDataSetChanged();
    }

    public List<RecyclerViewItem> getItems() {
        return mItems;
    }
}<commit_msg>Added missing methods from last commit<commit_after>package com.jamieadkins.commonutils.ui;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.ViewGroup;

import com.jamieadkins.commonutils.R;

import java.util.ArrayList;
import java.util.List;

/**
 * Holds base logic for recycler view adapters.
 */

public abstract class BaseRecyclerViewAdapter
        extends RecyclerView.Adapter<BaseViewHolder> {
    private List<RecyclerViewItem> mItems;

    public RecyclerViewItem getItemAt(int position) {
        return mItems.get(position);
    }

    public BaseRecyclerViewAdapter() {
        mItems = new ArrayList<>();
    }

    @Override
    public int getItemCount() {
        if (mItems == null) {
            return 0;
        } else {
            return mItems.size();
        }
    }

    @Override
    public int getItemViewType(int position) {
        return mItems.get(position).getItemType();
    }

    @Override
    public BaseViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        switch (viewType) {
            case Header.TYPE_HEADER:
                return new HeaderViewHolder(LayoutInflater.from(parent.getContext())
                        .inflate(R.layout.item_header, parent, false));
            case SubHeader.TYPE_SUB_HEADER:
                return new SubHeaderViewHolder(LayoutInflater.from(parent.getContext())
                        .inflate(R.layout.item_subheader, parent, false));
            case GoogleNowSubHeader.TYPE_GOOGLE_NOW_SUB_HEADER:
                return new GoogleNowSubHeaderViewHolder(LayoutInflater.from(parent.getContext())
                        .inflate(R.layout.item_google_subheader, parent, false));
            default:
                throw new RuntimeException("Detail level has not been implemented.");
        }
    }

    @Override
    public void onBindViewHolder(BaseViewHolder holder, int position) {
        holder.bindItem(mItems.get(position));
    }

    public void addItem(RecyclerViewItem item) {
        if (!mItems.contains(item)) {
            mItems.add(item);
            notifyDataSetChanged();
        }
    }

    public void addItem(int position, RecyclerViewItem item) {
        if (!mItems.contains(item)) {
            mItems.add(position, item);
            notifyDataSetChanged();
        }
    }

    public void removeItem(RecyclerViewItem itemToRemove) {
        mItems.remove(itemToRemove);
        notifyDataSetChanged();
    }

    public void removeItem(int index) {
        mItems.remove(index);
        notifyDataSetChanged();
    }

    public boolean isAnItemAt(int index) {
        return mItems.size() > index;
    }

    public void clear() {
        mItems.clear();
        notifyDataSetChanged();
    }

    public List<RecyclerViewItem> getItems() {
        return mItems;
    }
}
{'fraction_non_alphanumeric': 0.09246450673461959, 'fraction_numerical': 0.0007280669821623589, 'mean_word_length': 2.41728855721393, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4559385', 'n_tokens_mistral': 1552, 'n_tokens_neox': 1481, 'n_words': 308}