Extract recipe view holder to separate file
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
package gq.kirmanak.mealie.ui.recipes
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import gq.kirmanak.mealie.data.recipes.db.RecipeEntity
|
||||
import gq.kirmanak.mealie.databinding.ViewHolderRecipeBinding
|
||||
|
||||
class RecipeViewHolder(
|
||||
private val binding: ViewHolderRecipeBinding,
|
||||
private val recipeViewModel: RecipeViewModel
|
||||
) : RecyclerView.ViewHolder(binding.root) {
|
||||
fun bind(item: RecipeEntity?) {
|
||||
binding.name.text = item?.name
|
||||
recipeViewModel.loadRecipeImage(binding.image, item)
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,6 @@ import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import androidx.paging.PagingDataAdapter
|
||||
import androidx.recyclerview.widget.DiffUtil
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import gq.kirmanak.mealie.data.recipes.db.RecipeEntity
|
||||
import gq.kirmanak.mealie.databinding.ViewHolderRecipeBinding
|
||||
import timber.log.Timber
|
||||
@@ -25,16 +24,6 @@ class RecipesPagingAdapter(
|
||||
}
|
||||
}
|
||||
|
||||
class RecipeViewHolder(
|
||||
private val binding: ViewHolderRecipeBinding,
|
||||
private val recipeViewModel: RecipeViewModel
|
||||
) : RecyclerView.ViewHolder(binding.root) {
|
||||
fun bind(item: RecipeEntity?) {
|
||||
binding.name.text = item?.name
|
||||
recipeViewModel.loadRecipeImage(binding.image, item)
|
||||
}
|
||||
}
|
||||
|
||||
private object RecipeDiffCallback : DiffUtil.ItemCallback<RecipeEntity>() {
|
||||
override fun areItemsTheSame(oldItem: RecipeEntity, newItem: RecipeEntity): Boolean {
|
||||
return oldItem.localId == newItem.localId
|
||||
|
||||
Reference in New Issue
Block a user