I have been learning and integrating MVP pattern
, and have few questions.
What i have understand from this diagram, is that
Activity will create instance of Presenter
, and pass its reference and model
object to the presenter
MainPresenter mainPresenter = new MainPresenter(this, new MainModel());
Next if presenter need to store or get any data from local preference or remotely, it will ask model.
And then model will ask repository for storing and retrieving data.
I followed few tutorials and this is how i implement the pattern.
Interface
public interface MainActivityMVP {
public interface Model{
}
public interface View{
boolean isPnTokenRegistered();
}
public interface Presenter{
}
}
Activity
MainPresenter mainPresenter = new MainPresenter(this, new MainModel());
mainPresenter.sendDataToServer();
Presenter
public void sendDataToServer() {
// Here i need to ask `model` to check
do network operation and save data in preference
}
Now the issue is i need context to access sharedPreference
, but i have not passed context
anywhere. I also don't want to use static context
. I want to know the proper way of passing context to MVP pattern.