Understanding MVP architecture. While I do not use any Dagger'ov, RxJava, etc., just trying to translate a simple application c MVC to MVP.

If an event occurs - "click on the 'add'" button in some form, then Presenter is twitching, ... it signals in the Model, ... there is an addition, and then the View / update screen changes with some new data. It seems clear here.

Question: if an event occurs in * View - "click on the list" of some entities and a new fragment is opened with the selected entity, i.e. (no data change occurs) as a matter of fact a transition from one View to another, does the Presenter layer participate here?

I have doubts about the moment when the entity - (data) on which the click occurred is transferred from one View to another like this:

View -> View

or through the Presenter to do it? Those. to transfer to Presenter the clicked data, and then it should transfer it to another View?

View -> Presenter -> View

Thank!

* View - in this question, exclusively, as a component of MVP, and not android.view.View

    1 answer 1

    Look, the MVP pattern is very wide, and there is no definite canon. Each uses differently. The simplest example of MVP is as follows.

    1. View - for example, this is our activity. In it we write:

      Presenter presenter = new Presenter (data);

    2. Presenter is a class in which a request is sent or some actions are done. If a request is sent, then the request receives a certain Model, which we will work with in the future. So here. Sent a request, got an answer, a certain model. Next, we call the method of our view, where we pass this model (data), in this method the view displays this data.

    3.Model is a class in which the structure of the server response, POJO, is described.

    That somehow it works.

    PS You may have a question regarding: "Um, what's the difference between MVP and MVC"? The main difference in the use of such as DataBinding allows you to bind the model to some view.

    • Thanks for feedback! I understand the difference between MVC and MVP, what Presenter does, Model and View is generally clear to me, but in my particular case it is not clear - Stanly T
    • one
      In your case, transfer data via view -> view. Usually via bandle or intent. Presentar use is redundant) - Martinez Toni
    • @StanlyT above wrote) - Martinez Toni