Skip to content

Instantly share code, notes, and snippets.

@danielmalone
Created January 24, 2020 03:20
Show Gist options
  • Save danielmalone/2e3d4da77a7b936893d0656e7af74486 to your computer and use it in GitHub Desktop.
Save danielmalone/2e3d4da77a7b936893d0656e7af74486 to your computer and use it in GitHub Desktop.
package com.danielmalone.podcast
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView
class PodcastsAdapter :
ListAdapter<Podcast, PodcastsAdapter.PodcastViewHolder>(PodcastDiffCallback()) {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): PodcastViewHolder {
val inflater = LayoutInflater.from(parent.context)
return PodcastViewHolder(inflater.inflate(R.layout.podcast_item, parent, false))
}
override fun onBindViewHolder(holder: PodcastViewHolder, position: Int) {
holder.bind(getItem(position))
}
class PodcastViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
fun bind(item: Podcast) {
}
}
}
class PodcastDiffCallback : DiffUtil.ItemCallback<Podcast>() {
override fun areItemsTheSame(oldItem: Podcast, newItem: Podcast): Boolean {
return true
}
override fun areContentsTheSame(oldItem: Podcast, newItem: Podcast): Boolean {
return true
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment