<commit_before>package com.agileandroid.ui.listeners.adapters.recycler;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.ViewGroup;

import com.agileandroid.ui.listeners.adapters.recycler.populator.Populator;
import com.agileandroid.ui.listeners.adapters.recycler.builder.AgileRecyclerBuilder;
import com.agileandroid.ui.listeners.adapters.recycler.builder.ViewResolverRecyclerBuilder;
import com.agileandroid.ui.listeners.adapters.recycler.dto.AgileAdapterDTORecycler;
import com.agileandroid.ui.listeners.adapters.view.dto.InteractorDTO;
import com.agileandroid.ui.listeners.adapters.recycler.holder.HolderRecycler;
import com.agileandroid.ui.listeners.adapters.recycler.interactor.Interactor;

import com.agileandroid.ui.listeners.adapters.recycler.resolver.ViewResolverRecycler;

import java.util.List;

/**
 * Created by oscar.urbina on 8/28/15.
 */
public class AgileRecyclerAdapter extends RecyclerView.Adapter<HolderRecycler>{

    /**
     * The Item list.
     */
    protected List itemList;
    private Context context;

    private AgileAdapterDTORecycler agileAdapterDTORecycler;

    /**
     * Instantiates a new Agile recycler adapter.
     *
     * @param itemList the item list
     * @param agileAdapterDTORecycler the agile adapter dTO
     */
    public AgileRecyclerAdapter(List itemList, AgileAdapterDTORecycler agileAdapterDTORecycler) {
        this.itemList = itemList;
        this.agileAdapterDTORecycler = agileAdapterDTORecycler;
    }

    /*
    @Override
    public int getItemViewType(int position) {
        return this.itemList.get(position).getItemType();
    }*/


    @Override
    public HolderRecycler onCreateViewHolder(ViewGroup parent, int viewType) {

        this.context = parent.getContext();

        final ViewResolverRecyclerBuilder viewResolverRecyclerBuilder =
                new ViewResolverRecyclerBuilder.Builder(parent, viewType)
                        .build();

        final ViewResolverRecycler viewResolverRecycler = this.agileAdapterDTORecycler.getViewResolverRecycler();
        viewResolverRecycler.setViewResolverRecyclerBuilder(viewResolverRecyclerBuilder);

        return viewResolverRecycler.resolve();
    }

    @Override
    public void onBindViewHolder(HolderRecycler holder, final int position) {

        final Object currentPostItem = this.itemList.get(position);

        AgileRecyclerBuilder agileRecyclerBuilder = new AgileRecyclerBuilder.Builder(holder)
                .setContext(this.context)
                .setItem(currentPostItem)
                .build();

        Populator populator = this.agileAdapterDTORecycler.getPopulator();
        populator.populate(agileRecyclerBuilder);

        if(this.agileAdapterDTORecycler.getInteractor() != null){

            this.handleCustomInteractions(agileRecyclerBuilder);
        }
    }

    /**
     * Add listeners to several view interactable items in current view
     *
     * @param agileRecyclerBuilder agileRecyclerBuilder Current holder element
     */
    private void handleCustomInteractions(AgileRecyclerBuilder agileRecyclerBuilder) {

        Interactor interactor = this.agileAdapterDTORecycler.getInteractor();
        interactor.setInteraction(agileRecyclerBuilder);
    }

    @Override
    public int getItemCount() {
        return this.itemList.size();
    }

    /**
     * Add post.
     *
     * @param item the item
     */
    public void addItem(Object item) {
        this.itemList.add(item);
        notifyDataSetChanged();
    }

    /**
     * Update posts list.
     *
     * @param newItemList the new item list
     */
    public void appendNewItemList(List<?> newItemList){

        for(Object item : newItemList){
            this.itemList.add(item);
        }
        notifyDataSetChanged();
    }

    /**
     * Clear posts list.
     */
    public void clearItemList() {
        this.itemList.clear();
        notifyDataSetChanged();
    }
}<commit_msg>Remove item method added<commit_after>package com.agileandroid.ui.listeners.adapters.recycler;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.ViewGroup;

import com.agileandroid.ui.listeners.adapters.recycler.populator.Populator;
import com.agileandroid.ui.listeners.adapters.recycler.builder.AgileRecyclerBuilder;
import com.agileandroid.ui.listeners.adapters.recycler.builder.ViewResolverRecyclerBuilder;
import com.agileandroid.ui.listeners.adapters.recycler.dto.AgileAdapterDTORecycler;
import com.agileandroid.ui.listeners.adapters.view.dto.InteractorDTO;
import com.agileandroid.ui.listeners.adapters.recycler.holder.HolderRecycler;
import com.agileandroid.ui.listeners.adapters.recycler.interactor.Interactor;

import com.agileandroid.ui.listeners.adapters.recycler.resolver.ViewResolverRecycler;

import java.util.List;

/**
 * Created by oscar.urbina on 8/28/15.
 */
public class AgileRecyclerAdapter extends RecyclerView.Adapter<HolderRecycler>{

    /**
     * The Item list.
     */
    protected List itemList;
    private Context context;
    private static final String LOG_TAG = AgileRecyclerAdapter.class.getSimpleName();

    private AgileAdapterDTORecycler agileAdapterDTORecycler;

    /**
     * Instantiates a new Agile recycler adapter.
     *
     * @param itemList the item list
     * @param agileAdapterDTORecycler the agile adapter dTO
     */
    public AgileRecyclerAdapter(List itemList, AgileAdapterDTORecycler agileAdapterDTORecycler) {
        this.itemList = itemList;
        this.agileAdapterDTORecycler = agileAdapterDTORecycler;
    }

    /*
    @Override
    public int getItemViewType(int position) {
        return this.itemList.get(position).getItemType();
    }*/


    @Override
    public HolderRecycler onCreateViewHolder(ViewGroup parent, int viewType) {

        this.context = parent.getContext();

        final ViewResolverRecyclerBuilder viewResolverRecyclerBuilder =
                new ViewResolverRecyclerBuilder.Builder(parent, viewType)
                        .build();

        final ViewResolverRecycler viewResolverRecycler = this.agileAdapterDTORecycler.getViewResolverRecycler();
        viewResolverRecycler.setViewResolverRecyclerBuilder(viewResolverRecyclerBuilder);

        return viewResolverRecycler.resolve();
    }

    @Override
    public void onBindViewHolder(HolderRecycler holder, final int position) {

        final Object currentPostItem = this.itemList.get(position);

        AgileRecyclerBuilder agileRecyclerBuilder = new AgileRecyclerBuilder.Builder(holder)
                .setContext(this.context)
                .setItem(currentPostItem)
                .build();

        Populator populator = this.agileAdapterDTORecycler.getPopulator();
        populator.populate(agileRecyclerBuilder);

        if(this.agileAdapterDTORecycler.getInteractor() != null){

            this.handleCustomInteractions(agileRecyclerBuilder);
        }
    }

    /**
     * Add listeners to several view interactable items in current view
     *
     * @param agileRecyclerBuilder agileRecyclerBuilder Current holder element
     */
    private void handleCustomInteractions(AgileRecyclerBuilder agileRecyclerBuilder) {

        Interactor interactor = this.agileAdapterDTORecycler.getInteractor();
        interactor.setInteraction(agileRecyclerBuilder);
    }

    @Override
    public int getItemCount() {
        return this.itemList.size();
    }

    /**
     * Add post.
     *
     * @param item the item
     */
    public void addItem(Object item) {
        this.itemList.add(item);
        super.notifyDataSetChanged();
    }

    /**
     * Update posts list.
     *
     * @param newItemList the new item list
     */
    public void appendNewItemList(List<?> newItemList){

        for(Object item : newItemList){
            this.itemList.add(item);
        }
        super.notifyDataSetChanged();
    }

    public void removeItemList(Object item){

        if(this.itemList.contains(item)){
            this.itemList.remove(item);
            super.notifyDataSetChanged();
            return;
        }

        Log.i(LOG_TAG, "Object not present, couldn´t remove");
    }

    /**
     * Clear posts list.
     */
    public void clearItemList() {
        this.itemList.clear();
        super.notifyDataSetChanged();
    }
}
{'fraction_non_alphanumeric': 0.0868267048847486, 'fraction_numerical': 0.0014331780723754925, 'mean_word_length': 3.110947471772214, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '3527647', 'n_tokens_mistral': 2527, 'n_tokens_neox': 2364, 'n_words': 421}