Created
January 24, 2020 03:20
-
-
Save danielmalone/2e3d4da77a7b936893d0656e7af74486 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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