Guest User

Untitled

a guest
Apr 14th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. /**
  2. * Hook called when the user requests to sign-in to the application
  3. */
  4. private fun onLoginMenuItemSelected(): Boolean {
  5. // Close the options menu
  6. closeOptionsMenu()
  7.  
  8. // Produce the Alert dialog with the login form
  9. val formView = layoutInflater.inflate(R.layout.login_form, null, false)
  10. val username = formView.find<EditText>(R.id.login_form_username)
  11. val password = formView.find<EditText>(R.id.login_form_password)
  12.  
  13. AlertDialog.Builder(this)
  14. .setView(formView)
  15. .setNegativeButton("Cancel") { _, _ -> toast("Cancelled") }
  16. .setPositiveButton("Sign In") { _, _ -> model.signin(username.getContent(), password.getContent()) }
  17. .show()
  18.  
  19. // We handled the request
  20. return true
  21. }
  22.  
  23. /**
  24. * Hook called when the user requests to sign-out of the application
  25. */
  26. private fun onLogoutMenuItemSelected(): Boolean {
  27. // Close the options menu
  28. closeOptionsMenu()
  29.  
  30. // Produce an Are You Sure? dialog
  31. alert("Are you sure you want to sign out?") {
  32. yesButton { model.signout() }
  33. noButton { }
  34. }.show()
  35.  
  36. // We handled the request
  37. return true
  38. }
Add Comment
Please, Sign In to add comment