<commit_before>package com.xhunter74.mailcomposer.adapters;

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

import com.xhunter74.mailcomposer.R;

import java.io.File;

/**
 * Created by Serhiy.Krasovskyy on 13.03.2016.
 */
public class AttachmentListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {

    private static final String TAG = AttachmentListAdapter.class.getName();
    private final Context mContext;
    private String[] mItems;

    public AttachmentListAdapter(Context context, String[] items) {
        mContext = context;
        mItems = items;
    }

    public void setItems(String[] items) {
        mItems = items;
        notifyDataSetChanged();
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(mContext).inflate(R.layout.item_attachment, parent, false);
        return new AttachmentViewHolder(view);

    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int position) {
        prepareAttachmentViewHolder(viewHolder, position);
    }

    private void prepareAttachmentViewHolder(RecyclerView.ViewHolder viewHolder, int position) {
        AttachmentViewHolder attachmentViewHolder = (AttachmentViewHolder) viewHolder;
        String fileName = getFileName(mItems[position]);
        attachmentViewHolder.mFileName.setText(fileName);
    }

    private String getFileName(String filePath) {
        File file = new File(filePath);
        return file.getName();
    }

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

    private class AttachmentViewHolder extends RecyclerView.ViewHolder {

        public final View mAttachmentContainer;
        public final TextView mFileName;

        public AttachmentViewHolder(View view) {
            super(view);
            mAttachmentContainer = view.findViewById(R.id.item_attachment_container);
            mFileName = (TextView) view.findViewById(R.id.item_attachment_file_name);
        }
    }
}
<commit_msg>Added long touch listener.<commit_after>package com.xhunter74.mailcomposer.adapters;

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

import com.xhunter74.mailcomposer.R;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by Serhiy.Krasovskyy on 13.03.2016.
 */
public class AttachmentListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {

    private static final String TAG = AttachmentListAdapter.class.getName();
    private final Context mContext;
    private final List<OnAttachmentClick> mOnAttachmentClicks;
    private String[] mItems;

    public AttachmentListAdapter(Context context, String[] items) {
        mContext = context;
        mItems = items;
        mOnAttachmentClicks = new ArrayList<>();
    }

    public void setOnAttachmentClickListeners(OnAttachmentClick onAttachmentClick) {
        mOnAttachmentClicks.add(onAttachmentClick);
    }

    public void setItems(String[] items) {
        mItems = items;
        notifyDataSetChanged();
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(mContext).inflate(R.layout.item_attachment, parent, false);
        return new AttachmentViewHolder(view);

    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int position) {
        prepareAttachmentViewHolder(viewHolder, position);
    }

    private void prepareAttachmentViewHolder(RecyclerView.ViewHolder viewHolder, final int position) {
        AttachmentViewHolder attachmentViewHolder = (AttachmentViewHolder) viewHolder;
        final String fileName = getFileName(mItems[position]);
        attachmentViewHolder.mFileName.setText(fileName);
        attachmentViewHolder.mAttachmentContainer.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
                for (OnAttachmentClick onAttachmentClick : mOnAttachmentClicks) {
                    onAttachmentClick.onClick(position);
                }
                return false;
            }
        });
    }

    private String getFileName(String filePath) {
        File file = new File(filePath);
        return file.getName();
    }

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

    public interface OnAttachmentClick {
        void onClick(int position);
    }

    private class AttachmentViewHolder extends RecyclerView.ViewHolder {

        public final View mAttachmentContainer;
        public final TextView mFileName;

        public AttachmentViewHolder(View view) {
            super(view);
            mAttachmentContainer = view.findViewById(R.id.item_attachment_container);
            mFileName = (TextView) view.findViewById(R.id.item_attachment_file_name);
        }
    }
}

{'fraction_non_alphanumeric': 0.08069270449521002, 'fraction_numerical': 0.005158437730287398, 'mean_word_length': 3.112878787878788, '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': '682605', 'n_tokens_mistral': 1489, 'n_tokens_neox': 1437, 'n_words': 319}