Advertisement
Guest User

Untitled

a guest
Mar 28th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. class SignInPresenter(private val api: ApiController, view: SignInView, private val state: SignInState) {
  2.  
  3. private val view = WeakReference(view)
  4.  
  5. fun signIn(email: String, password: String) {
  6. api.signIn(email, password).enqueue(object : RetrofitCallback<User>() {
  7. override fun onSuccess(t: User) {
  8. state.user = t
  9. view.get()?.onSignIn(t)
  10. }
  11.  
  12. override fun onError(t: Throwable) {
  13. view.get()?.onError(t)
  14. }
  15. })
  16. }
  17.  
  18. interface SignInView {
  19. fun onSignIn(t: User)
  20. fun onError(t: Throwable) // is IOException | AccountInactive | Unauthorized | ContractViolation
  21. }
  22.  
  23. interface SignInState {
  24. var user: User?
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement