Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
MovieHunt blog part5 view model pattern model
@EpoxyModelClass(layout = R.layout.holder_movie_landscape)
abstract class MovieListEpoxyModel : EpoxyModelWithHolder<MovieListEpoxyModel.Holder>() {
@EpoxyAttribute
var movieId = ""
@EpoxyAttribute
var imagePoster = ""
...
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash)
var itemClickListener: (String) -> Unit = {}
override fun bind(holder: Holder) {
Glide.with(holder.imagePoster)
.load(imagePoster)
.error(R.color.darkBlue)
.placeholder(R.color.darkBlue)
.into(holder.imagePoster)
...
holder.itemView.setOnClickListener { itemClickListener(movieId) }
}
class Holder : EpoxyHolder() {
lateinit var itemView: View
lateinit var imagePoster: ImageView
...
override fun bindView(itemView: View) {
this.itemView = itemView
imagePoster = itemView.findViewById(R.id.imagePoster)
...
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment