Android-CleanArchitecture icon indicating copy to clipboard operation
Android-CleanArchitecture copied to clipboard

Refactor presentation MVP presenters and views

Open ihorvitruk opened this issue 9 years ago • 2 comments

ihorvitruk avatar Jan 26 '17 16:01 ihorvitruk

@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).

ihorvitruk avatar Mar 07 '17 13:03 ihorvitruk

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

alexandru-calinoiu avatar Mar 22 '17 12:03 alexandru-calinoiu