P layer connects model and view. The data is loaded in the model layer, and the P layer calls the method of the model layer. The effect display is processed in the view layer. The P layer calls the method of the model layer. After getting the data, it interacts with the view layer. I don’t know if this explanation is clear.
The main task of the p layer is to handle various logics
I think one of the shortcomings of MVP is that it requires writing a lot of interfaces and code. If an activity has few enough tasks (for example, there is only one listview requesting the network), the logic can be written directly in the activity. There is no need to force MVP
I think data (including network requests and JSON parsing) should be placed on the V layer. Set up a callback interface to send the processed data to the P layer. If the data needs to be updated to the V layer, the P layer will push it to the V layer. render. (Words from a newbie)
presenter 主要是做逻辑层,你说的数据加载这些被许多人称为ModelLayer, the presenter just controls various logics. If you can take a look at this video and the google open source sample on github
Presenter coordinates View and Model. The intuitive feeling is the control logic between V-M.
Model changes callback to View through Presenter; View changes callback to Model through Presenter; in this way, Model and View are not tightly coupled, which improves encapsulation and reuse value to a certain extent, which is stronger than MVC...
Presenter is simply the bridge between View and Model. On the one hand, the Presenter method is called in the View to implement logical control, and then the Presenter calls the method in the Model to perform specific data request work, and then through callbacks, the Presenter Pass it to View and render the data. I think you need two examples to understand the MVP model. I recommend two: 1, StylishMusic 2, LookLook
P layer connects model and view.
The data is loaded in the model layer, and the P layer calls the method of the model layer.
The effect display is processed in the view layer. The P layer calls the method of the model layer. After getting the data, it interacts with the view layer. I don’t know if this explanation is clear.
The main task of the p layer is to handle various logics
I think one of the shortcomings of MVP is that it requires writing a lot of interfaces and code. If an activity has few enough tasks (for example, there is only one listview requesting the network), the logic can be written directly in the activity. There is no need to force MVP
I think data (including network requests and JSON parsing) should be placed on the V layer. Set up a callback interface to send the processed data to the P layer. If the data needs to be updated to the V layer, the P layer will push it to the V layer. render. (Words from a newbie)
presenter
主要是做逻辑层,你说的数据加载这些被许多人称为Model
Layer, the presenter just controls various logics. If you can take a look at this video and the google open source sample on githubPresenter coordinates View and Model. The intuitive feeling is the control logic between V-M.
Model changes callback to View through Presenter; View changes callback to Model through Presenter; in this way, Model and View are not tightly coupled, which improves encapsulation and reuse value to a certain extent, which is stronger than MVC...
Presenter is simply the bridge between View and Model. On the one hand, the Presenter method is called in the View to implement logical control, and then the Presenter calls the method in the Model to perform specific data request work, and then through callbacks, the Presenter Pass it to View and render the data. I think you need two examples to understand the MVP model. I recommend two:
1, StylishMusic
2, LookLook