Actually, at first everything is clear - we have 3 parts - model, present, view, but I have questions about the implementation of each of them in android.

As far as I understand from reading earlier

  1. All layouts are replaced with fragments, so we have only 1 layout with 1 element - FrameLayout (this is the most unusual for me, I understand logically, but still it seems that something is wrong here)

  2. View

    • MainActivity class with fragment replacement method
    • Class for each fragment with initial settings of type onClickListner'ov in onCreate'e and methods of type makeToast
  3. Present

    • For each fragment of the present
    • Can there be additional classes in this part? For example the class responsible for working with user data?
  4. Model

    • I do not understand a bit how to implement it so that the data would be available in all present? Maybe I misunderstand how this part should be implemented and the model should not store anything in itself, but only receive data from other places (SharedPreferences, SQLite, etc.)? In this case, in each gift you just need to create a new model?
  • If you are given an exhaustive answer, mark it as correct (a daw opposite the selected answer). - Nicolas Chabanovsky

1 answer 1

If in a nutshell:

  1. View - the most stupid object (Activity, Fragment, View). Itself solves nothing, is controlled from Presenter'a. It has methods ala "showData (Data data)", "show Error Loading ()". Layout is just a layout. I would include it in the View, since the interface can be displayed without layouts.
  2. Presenter - a piece that contains all the logic of the application. Better, yes, so that for each View there is one Presenter (so that there is not one huge presenter).
  3. Model - responsible for receiving and caching data.

Implementations and libraries a lot. Read in Russian - google "android mvp habrahabr". But in general, if you just start learning Android, MVP is not the first thing to start learning with. Only you will get more confused in the lifesike = /

  • I have the biggest question right now - how to transfer data between different fragments. What would you advise to build the architecture of the first simple, but serious android application? What pattern to use? - user3239600
  • one
    @user3239600 I would recommend using a data bus, such libraries as Otto or EventBus is at the same time the easiest, most transparent and most efficient way, because it allows you to transfer anything directly. - pavlofff