Skip to content

Instantly share code, notes, and snippets.

@anitaa1990
Created August 13, 2024 10:26
Show Gist options
  • Save anitaa1990/0121897d6c90181582c9273a08b5524a to your computer and use it in GitHub Desktop.
Save anitaa1990/0121897d6c90181582c9273a08b5524a to your computer and use it in GitHub Desktop.
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
val movie = movies[position]
holder.title.text = movie.title
holder.rating.text = movie.rating
// SRP violation, onBindViewHolder has only the responsibility to display data
// & not make data formatting operations
val genres = movie.genres
val builder = StringBuilder()
for (genre in genres) {
builder.append(genre).append(",")
}
holder.genres.text = builder.toString()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment