I am trying to understand MVP design pattern practically and went through this link and few other links and made some observation. I want to know that all the below observations are correct for implementing MVP design pattern practically?
Activity
,Fragment
s and ourxml
layouts will be part of View.Our POJO classes or the classes which are responsible for fetching data, making API calls or calling Web services are part of Model.
We create an interface which contains abstract methods for various events we need to perform on View or various events for the lifecycle of view.
Activity
/Fragment
will implement that interface and pass its reference to Presenter constructor.Presenter will have reference to both View and Model. Its constructor will contain reference to an interface which
Activity
implemented and it will create an object of Model.Whenever an action is performed on View or for any lifecycle callback of View, a method of Presenter is called from View. That method will interact with both Model and View as per requirement. It will call method of Model and will call the method of interface that
Activity
implemented so both Model and View can perform action in their classes.