Created
June 17, 2019 11:20
-
-
Save TobiAlbert/c2a28cc009b635bd8910a115c3a02cf5 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
class RoomAdapter(val championId: String) : RecyclerView.Adapter<RoomViewHolder>() { | |
private var messages = mutableListOf<Message>() | |
fun addMessage(message: Message) { | |
messages.add(message) | |
notifyItemChanged(messages.size - 1) | |
} | |
override fun onCreateViewHolder(parent: ViewGroup, layoutResource: Int): RoomViewHolder = | |
RoomViewHolder.create(parent) | |
override fun getItemCount(): Int = messages.size | |
override fun onBindViewHolder(holder: RoomViewHolder, position: Int) = | |
holder.bind(messages[position], championId) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment