Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Hook called when the user requests to sign-in to the application
- */
- private fun onLoginMenuItemSelected(): Boolean {
- // Close the options menu
- closeOptionsMenu()
- // Produce the Alert dialog with the login form
- val formView = layoutInflater.inflate(R.layout.login_form, null, false)
- val username = formView.find<EditText>(R.id.login_form_username)
- val password = formView.find<EditText>(R.id.login_form_password)
- AlertDialog.Builder(this)
- .setView(formView)
- .setNegativeButton("Cancel") { _, _ -> toast("Cancelled") }
- .setPositiveButton("Sign In") { _, _ -> model.signin(username.getContent(), password.getContent()) }
- .show()
- // We handled the request
- return true
- }
- /**
- * Hook called when the user requests to sign-out of the application
- */
- private fun onLogoutMenuItemSelected(): Boolean {
- // Close the options menu
- closeOptionsMenu()
- // Produce an Are You Sure? dialog
- alert("Are you sure you want to sign out?") {
- yesButton { model.signout() }
- noButton { }
- }.show()
- // We handled the request
- return true
- }
Add Comment
Please, Sign In to add comment