MVP for Android Apps
I’ve been working on my first (and very simple) Android application. I’ve been using a Model View Presenter approach and wondering if this is a typical pattern used by Android developers.
The main Activity is acting as the view and I pass it into the Presenter so both are aware of each other as illustrated below. The Presenter itself implements an IObserver interface that watches for state changes in the model, by having the model call IObserver.update. The Presenter then queries the Model’s state.
The Model’s job is to manage it’s own state and that of the ViewModels it returns, which are then bound to the Activity by the Presenter.
It seems to working quite well for me and avoids all the approaches I see online wherein people put business logic into the Activity itself.