Skip to content

Instantly share code, notes, and snippets.

@jetaggart
Created June 29, 2020 18:37
Show Gist options
  • Select an option

  • Save jetaggart/02ff32b36e7c2ee63576c6c211e3c1fb to your computer and use it in GitHub Desktop.

Select an option

Save jetaggart/02ff32b36e7c2ee63576c6c211e3c1fb to your computer and use it in GitHub Desktop.
// android/app/src/main/java/io/getstream/thestream/MainActivity.kt:16
class MainActivity : AppCompatActivity(), CoroutineScope by MainScope() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val submit: Button = findViewById(R.id.submit)
val userView: EditText = findViewById(R.id.user)
submit.setOnClickListener {
val user: String = userView.text.toString()
launch(Dispatchers.IO) {
BackendService.signIn(user)
val chatCredentials = BackendService.getChatCredentials()
launch(Dispatchers.Main) {
ChatService.init(applicationContext, user, chatCredentials)
startActivity(
Intent(applicationContext, AuthedMainActivity::class.java)
)
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment