Skip to content

Instantly share code, notes, and snippets.

@illuzor
Created September 17, 2018 21:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save illuzor/03e302aa035e990248249760737eff33 to your computer and use it in GitHub Desktop.
Save illuzor/03e302aa035e990248249760737eff33 to your computer and use it in GitHub Desktop.
package com.illuzor.lesson.wallpapers.adapters
import android.view.LayoutInflater
import android.view.ViewGroup
import com.illuzor.lesson.wallpapers.R
import com.illuzor.lesson.wallpapers.api.BASE_URL
import com.illuzor.lesson.wallpapers.model.Category
class CategoriesAdapter : AbstractAdapter<Category, CategoryViewHolder>() {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) =
CategoryViewHolder(LayoutInflater.from(parent.context).inflate(R.layout.item_category, parent, false))
override fun onBindViewHolder(holder: CategoryViewHolder, position: Int) {
val item = getItem(position)
holder.setTitle(item.name)
holder.loadImage("$BASE_URL${item.preview}")
holder.itemView.setOnClickListener { clickListener(item.name) }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment