Skip to content
Advertisement

Android MVP – Calls the server

I started to learn MVP but I have a few questions related the communication between the Model and the Presenter, for example a login feature

  • Activity will get all the fields, send to the presenter, the presenter will validate and if it’s everything as expected the presenter will call the model to send to the server, but this call could take a few seconds, so I need to wait for the callback from the server to call the presenter again and the presenter calls the activity.

My question is: How is the best way to do that? At the moment I added a loginServerCallback() in my presenter and I pass the reference to the Model, so when the model finishes, I call the loginServerCallback() in the presenter and the presenter analyse the response and call the method in the View. Am I doing that right?

JavaScript

Thanks, Thales

Advertisement

Answer

add one more callback

JavaScript

And call login method in presenter like this

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement