<commit_before>package org.stepic.droid.ui.adapters

import android.support.v7.widget.RecyclerView
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import kotlinx.android.synthetic.main.catalog_item.view.*
import org.stepic.droid.R
import org.stepic.droid.model.CourseListItem
import org.stepic.droid.model.CoursesCarouselColorType
import org.stepic.droid.model.CoursesCarouselInfo
import org.stepic.droid.storage.operations.Table

class CatalogAdapter(
        private val courseListItems: List<CourseListItem>
) : RecyclerView.Adapter<RecyclerView.ViewHolder>() {

    companion object {
        private const val CAROUSEL_TYPE = 0
    }

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
        val layoutInflater = LayoutInflater.from(parent.context)
        return when (viewType) {
            CAROUSEL_TYPE -> {
                val view = layoutInflater.inflate(R.layout.catalog_item, parent, false)
                CarouselViewHolder(view)
            }
            else -> throw IllegalStateException("CatalogAdapter viewType = $viewType is unsupported")
        }
    }

    override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
        (holder as CarouselViewHolder).bindData(position)
//
//        when (getItemViewType(position)) {
//            CAROUSEL_TYPE -> (holder as CarouselViewHolder).bindData(courseListItemBy(adapterPosition = position))
//        }
    }

    private fun courseListItemBy(adapterPosition: Int) {
        courseListItems[adapterPosition]
    }

    override fun getItemCount(): Int = 10

    override fun getItemViewType(position: Int): Int = CAROUSEL_TYPE

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

        private val coursesCarousel = itemView.coursesCarouselItem

        fun bindData(position: Int) {
            val my = CoursesCarouselInfo(
                    CoursesCarouselColorType.Light,
                    itemView.resources.getString(R.string.my_courses_title),
                    Table.enrolled,
                    null)

            val popular = CoursesCarouselInfo(
                    CoursesCarouselColorType.Dark,
                    itemView.resources.getString(R.string.popular_courses_title),
                    Table.featured,
                    null)

            val info =
                    if (position % 2 == 0) {
                        my
                    } else {
                        popular
                    }

            coursesCarousel.setCourseCarouselInfo(info)


        }

    }
}<commit_msg>revert CatalogAdapter for showing course lists<commit_after>package org.stepic.droid.ui.adapters

import android.support.v7.widget.RecyclerView
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import kotlinx.android.synthetic.main.catalog_item.view.*
import org.stepic.droid.R
import org.stepic.droid.model.CourseListItem

class CatalogAdapter(
        private val courseListItems: List<CourseListItem>
) : RecyclerView.Adapter<RecyclerView.ViewHolder>() {

    companion object {
        private const val CAROUSEL_TYPE = 0
    }

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
        val layoutInflater = LayoutInflater.from(parent.context)
        return when (viewType) {
            CAROUSEL_TYPE -> {
                val view = layoutInflater.inflate(R.layout.catalog_item, parent, false)
                CarouselViewHolder(view)
            }
            else -> throw IllegalStateException("CatalogAdapter viewType = $viewType is unsupported")
        }
    }

    override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
        when (getItemViewType(position)) {
            CAROUSEL_TYPE -> (holder as CarouselViewHolder).bindData(courseListItemBy(adapterPosition = position))
        }
    }

    private fun courseListItemBy(adapterPosition: Int): CourseListItem = courseListItems[adapterPosition]

    override fun getItemCount(): Int = courseListItems.size

    override fun getItemViewType(position: Int): Int = CAROUSEL_TYPE

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

        private val coursesCarousel = itemView.coursesCarouselItem

        fun bindData(courseListItem: CourseListItem) {


        }

    }
}
{'fraction_non_alphanumeric': 0.08030678998420934, 'fraction_numerical': 0.0018046469659372885, 'mean_word_length': 2.6766169154228856, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, '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': '1217888', 'n_tokens_mistral': 1279, 'n_tokens_neox': 1173, 'n_words': 235}