androidandroid-fragmentsmvppresenter

Where to call for web API in Android MVP


I want to know what is the role of presenters in Android application development? And where should I call the data APIs?

Should I send my data requests inside the presenter or inside the (fragment / activity)?

Also, what is the role of the fragment/activity in MVP?

If you have any resources in this matter, they will be appreciated.


Solution

  • It depends on your MVP variant.

    But data requests go in your data classes, called from the Presenter. XXXDataManager for example. Where XXX is the model class you are fetching.

    Fragment/Activity is usually regarded as dumb views in MVP.

    Resource: https://medium.com/@cervonefrancesco/model-view-presenter-android-guidelines-94970b430ddf