Last active
May 6, 2020 12:57
-
-
Save samiuelson/5599a26ba145db5cda7bed774c8eb0b7 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 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