简体   繁体   中英

My MVP pattern approach in android

I am trying to implement MVP in my android project. I have the view which is basically my activity. which I am trying to make basically a dumb view so It calls my presenter to do all of its work.

I have a presenter class, which acts as an intermediary between the model and the View and finally the model Which I use to retrieve and save the data that needs to be represented in the view and is passed back via the presenter. I hope this is correct so far?

Basically I want to create and Gridlayout of Image buttons in my Mainactivity(view). These image buttons will basically be thumbnails from a folder on the phone. So basically my model will parse a folder and return Images to my view. my question is should Iterate over the images in the View as the View is meant to be dumb? I feel it shouldn't although on the other hand this is essentially UI logic, as it is creating a view and only dealing with a bunch of UI elements (Images).Any help is appreciated.

Your view has not to be completely Dumb.

It should know how to present the data to the user and interact with him/her.

In your case, you could have a view taking a lot of images and showing them as thumbnails for phones and handling touch screen features, while another view that would display differently on computer screen for example and be specific to mouse gesture.

You could keep for both the same model/presenter.

On a side note, I'm relatively new to Android development and I'm not sure if MVP is usually used in Android dev.


Here is a question which was asked about MVP being useful or not for Android dev : https://softwareengineering.stackexchange.com/questions/133134/is-model-view-presenter-mvp-scheme-useful-for-android

Another here : Comments on my MVP pattern for Android

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM