<commit_before>package jp.cordea.mackerelclient.adapter

import android.support.v4.app.Fragment
import android.support.v7.widget.RecyclerView
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import jp.cordea.mackerelclient.R
import jp.cordea.mackerelclient.activity.MonitorDetailActivity
import jp.cordea.mackerelclient.api.response.Monitor
import kotterknife.bindView

class MonitorAdapter(
        val fragment: Fragment,
        val items: List<Pair<String, Monitor?>>
) : RecyclerView.Adapter<RecyclerView.ViewHolder>() {

    override fun onBindViewHolder(holder: RecyclerView.ViewHolder?, position: Int) {
        val context = fragment.context ?: return
        (holder as? ViewHolder)?.apply {
            items[position].second?.let { item ->
                cell.setOnClickListener {
                    val intent = MonitorDetailActivity.createIntent(context, item)
                    fragment.startActivityForResult(intent, MonitorDetailActivity.RequestCode)
                }
                if (!item.name.isNullOrBlank()) {
                    name.text = item.name
                }
                id.text = item.id
                return
            }
            title.text = items[position].first
        }
    }

    override fun onCreateViewHolder(parent: ViewGroup?, viewType: Int): RecyclerView.ViewHolder? {
        var view = LayoutInflater.from(fragment.context).inflate(R.layout.list_item_monitor, parent, false)
        if (viewType == 1) {
            view = LayoutInflater.from(fragment.context).inflate(R.layout.list_item_monitor_section, parent, false)
        }
        return ViewHolder(view)
    }

    override fun getItemViewType(position: Int): Int {
        return if (items[position].second == null) 1 else 0
    }

    override fun getItemCount(): Int {
        return items.size
    }

    private class ViewHolder(val view: View) : RecyclerView.ViewHolder(view) {
        val cell: View by bindView(R.id.cell)

        val title: TextView by bindView(R.id.title)
        val name: TextView by bindView(R.id.name)
        val id: TextView by bindView(R.id.id)
    }
}<commit_msg>divide view holder<commit_after>package jp.cordea.mackerelclient.adapter

import android.support.v4.app.Fragment
import android.support.v7.widget.RecyclerView
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import jp.cordea.mackerelclient.R
import jp.cordea.mackerelclient.activity.MonitorDetailActivity
import jp.cordea.mackerelclient.api.response.Monitor
import kotterknife.bindView

class MonitorAdapter(
        val fragment: Fragment,
        val items: List<Pair<String, Monitor?>>
) : RecyclerView.Adapter<RecyclerView.ViewHolder>() {

    override fun onBindViewHolder(holder: RecyclerView.ViewHolder?, position: Int) {
        val context = fragment.context ?: return
        (holder as? ViewHolder)?.run {
            items[position].second?.let { item ->
                cell.setOnClickListener {
                    val intent = MonitorDetailActivity.createIntent(context, item)
                    fragment.startActivityForResult(intent, MonitorDetailActivity.RequestCode)
                }
                if (!item.name.isNullOrBlank()) {
                    name.text = item.name
                }
                id.text = item.id
                return
            }
        }
        (holder as? SectionViewHolder)?.run {
            title.text = items[position].first
        }
    }

    override fun onCreateViewHolder(parent: ViewGroup?, viewType: Int): RecyclerView.ViewHolder {
        if (viewType == 1) {
            val view = LayoutInflater.from(fragment.context)
                    .inflate(R.layout.list_item_monitor_section, parent, false)
            return SectionViewHolder(view)
        }
        val view = LayoutInflater.from(fragment.context)
                .inflate(R.layout.list_item_monitor, parent, false)
        return ViewHolder(view)
    }

    override fun getItemViewType(position: Int): Int {
        return if (items[position].second == null) 1 else 0
    }

    override fun getItemCount(): Int {
        return items.size
    }

    private class ViewHolder(val view: View) : RecyclerView.ViewHolder(view) {

        val cell: View by bindView(R.id.cell)
        val name: TextView by bindView(R.id.name)
        val id: TextView by bindView(R.id.id)
    }

    private class SectionViewHolder(val view: View) : RecyclerView.ViewHolder(view) {

        val title: TextView by bindView(R.id.title)
    }
}
{'fraction_non_alphanumeric': 0.09358115409552625, 'fraction_numerical': 0.002161227577263886, 'mean_word_length': 2.5167173252279635, 'pattern_counts': {'":': 0, '<': 9, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3957531', 'n_tokens_mistral': 1349, 'n_tokens_neox': 1276, 'n_words': 272}