Skip to content

Instantly share code, notes, and snippets.

@weverb2
Created January 22, 2019 01:10
Show Gist options
  • Save weverb2/2def45390ca1a87bcc7a7e16627ae837 to your computer and use it in GitHub Desktop.
Save weverb2/2def45390ca1a87bcc7a7e16627ae837 to your computer and use it in GitHub Desktop.
class MainActivity : AppCompatActivity() {
lateinit var viewModel: MainViewModel
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
viewModel = ViewModelProviders.of(this).get(MainViewModel::class.java)
username.doAfterTextChanged { text -> viewModel.username = text?.toString() ?: "" }
password.doAfterTextChanged { text -> viewModel.password = text?.toString() ?: "" }
viewModel.isFormValid.observe(this, Observer { valid ->
login.isEnabled = valid ?: false
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment