mercredi 28 mars 2018

Android MVP How to get data back from model to presenter

After some time developing personal Android Applications I found that usually Activities get really big and have both logic and UI operations quite mixed up.

So looking for a way to separate logic from UI I came across MVP pattern and now I'm trying to implement it in the application I'm going to develop.

So basically this would be my approach:

enter image description here

The issue I'm facing now is that in order to get data back from model to presenter I'd do something like this:

public static ModelManager (OnePresenter presenter)
{
    localPresenter = presenter
}

And then:

public onReturnData(){
    localPresenter.returnData();
}

The issue is that Model Manager could be called from any presenter at any time so how could I pass a reference of a Generic Presenter?

Thanks a lot.

Aucun commentaire:

Enregistrer un commentaire