Skip to content

Instantly share code, notes, and snippets.

@nparsons08 nparsons08/ChannelActivity.kt Secret

Created Mar 10, 2020
What would you like to do?
// com/example/bubblechat/ChannelActivity.kt:14
class ChannelActivity : AppCompatActivity() {
private var viewModel: ChannelViewModel? = null
private var binding: ActivityChannelBinding? = null
override fun onCreate(savedInstanceState: Bundle?) {
val channelType = intent.getStringExtra(EXTRA_CHANNEL_TYPE)
val channelID = intent.getStringExtra(EXTRA_CHANNEL_ID)
val client = StreamChat.getInstance(application)
binding = DataBindingUtil.setContentView(this, R.layout.activity_channel)
binding!!.lifecycleOwner = this
val channel =, channelID)
viewModel = ViewModelProviders.of(
ChannelViewModelFactory(this.application, channel)
binding!!.viewModel = viewModel
binding!!.messageList.setViewModel(viewModel!!, this)
binding!!.messageInput.setViewModel(viewModel, this)
binding!!.channelHeader.setViewModel(viewModel, this)
companion object {
private val EXTRA_CHANNEL_TYPE = "com.example.bubblechat.CHANNEL_TYPE"
private val EXTRA_CHANNEL_ID = "com.example.bubblechat.CHANNEL_ID"
fun newIntent(context: Context, channel: Channel): Intent {
val intent = Intent(context,
intent.putExtra(EXTRA_CHANNEL_TYPE, channel.type)
return intent
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.