Questions on the MVP Template for Android Applications

I have been developing Android apps for several years. I recently used the MVP architecture in my application and after reading and using this Android10 github repo many times.

But there are a few questions that I have around this MVP architecture that I am looking for. Please help me understand them better.

1) So, I have three modules of the application, domain, data. Which host modules will go. In some application, you have this in the domain, but I saw that some other libraries have it in the presentation or application module, for example https://github.com/android10/Android-CleanArchitecture .

2) Can presenters have Android-related products like Intents, Contexts, SharedPrefs ets? I do not think this should happen.

3) Can the data module talk to the application module and vice versa. Or the application module must talk to the domain module, which in terms of doing things in the data module.

4) How can I make a social login like Facebook with MVP architecture ... any idea or link for an explanation? I have done it below:

Activity: onFBButtonClick()presenter.onButtonClick()FacebookLoginManager.registerCallback

After that, I directly receive my activity onActivityResult(int requestcode, int resultcode, Intent intent) on onActivityResult(int requestcode, int resultcode, Intent intent) . Now, according to the fb sdk tutorial, I need to call FbCallbackManager.onActivityResult(with all the params) . But I can not convey this information in the presenter, because the presenter does not need to know about the intention (Platform Specific). How can I now call FbcallbackManager.onActivity() ?

+5
source share
1 answer

There are many approaches to implementing MVP in Android.

Most of the approaches I've seen designate Activity / Fragment as a representation of MVP. At first, this seems natural, but too many questions and questions arise when trying to apply this scheme to non-trivial applications.

After I explored many MVP approaches (including the ones you linked), I came to the conclusion that none of the actions without a fragment should not be MVC representations.

A detailed explanation of this claim is given here: Why actions are not user interface elements .

Following this line of sight, I proposed another implementation of MVP for Android applications: MVP and MVC Architectures in Android .

Regarding your questions:

  • The host is part of the "screen"
  • Depends on your chosen MVP approach. I personally think that the speakers are Actions and Fragments, so they may have dependencies on Android components.
  • I think that only the author of this git repo can answer this question.
  • If you accept the thinking of Activity / Fragment as a host, you will immediately understand how to do it without polluting the MVP views.

Also, regarding FB integration, see my answer here .

+2
source

Source: https://habr.com/ru/post/1262736/


All Articles