Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
class LiveStreamActivity : AppCompatActivity(R.layout.activity_main) {
private val adapter = MessagesListAdapter()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
loadMockVideoStream()
messagesList.adapter = adapter
val viewModel: LiveStreamViewModel by viewModels()
sendMessageButton.setOnClickListener {
viewModel.sendButtonClicked(messageInput.text.toString())
messageInput.setText("")
messageInput.clearFocus()
messageInput.hideKeyboard()
}
}
private fun updateMessagesList(messages: List<Message>) {
adapter.submitList(messages)
adapter.notifyDataSetChanged()
val scrollTarget = adapter.itemCount
messagesList.scrollToPosition(scrollTarget)
}
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.