Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor presentation MVP presenters and views #214

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

ihorvitruk
Copy link

No description provided.

@ihorvitruk
Copy link
Author

ihorvitruk commented Mar 7, 2017

@tmingos Thanks for your feedback about my refactoring! I really appreciate it.
About your question:
Thanks for pointing this. Yes, sure, it should be

public abstract class BaseFragment<PRESENTER extends Presenter<VIEW>, VIEW extends View> extends Fragment {

I have updated my pull request with your suggestion.
BTW: now I doubt a bit if BaseFragment (as an implementation if a View) should have a reference to Presenter at all.
So how I would change it? I would divide View into 2 interfaces: ViewInput and ViewOutput.
BaseFragment would implement ViewInput and has a reference to ViewOutput (instead of a reference to Presenter). And Presenter would implement ViewOutput (by other words, View will delegate all actions to Presenter, e.g: onViewCreated, onButtonClicked etc).

@alexandru-calinoiu
Copy link

Very cool refactoring, using MVP in this way makes more sens.

What I don't really like about MVP in android is that the presenter holds a reference to the view and views in android have a lifecycle, I had separated this via a contract, very similar to the implementation discussed in this article https://medium.com/@manuelvicnt/rxjava2-android-mvvm-lifecycle-app-structure-with-retrofit-2-cf903849f49e#.kx4cntcyi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants