Skip to content

Instantly share code, notes, and snippets.

@prof18
Created May 20, 2019 20:34
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 prof18/e87faf5172914a0ef4190deba00a8cbc to your computer and use it in GitHub Desktop.
Save prof18/e87faf5172914a0ef4190deba00a8cbc to your computer and use it in GitHub Desktop.
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
class ${NAME}(val items: MutableList<${ITEM_CLASS}>) : RecyclerView.Adapter<${NAME}.ViewHolder>() {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) = ViewHolder(LayoutInflater.from(parent.context).inflate(R.layout.${LAYOUT_RES_ID}, parent, false))
override fun getItemCount() = items.size
override fun onBindViewHolder(holder: ${NAME}.ViewHolder, position: Int) = holder.bind(items[position])
inner class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
fun bind(item: ${ITEM_CLASS}) {
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment