My Medium article to accompany this repo is here: Get your MVP right with Mosby
This repo explores Mosby and Mosby Conductor plugin implementing MVP pattern.
Both Mosby and Conductor have excellent documentation on GitHub and at Hannes Dorfmann's blog.
Model-View-Presenter (MVP) is hard to implement correctly (bug-free). Handling view state is another big challenge. There are many different implementations of MVP out there.
If there is a library that manages MVP wiring and view state for you so you can concentrate on your app logic and UI, why not check it out?
ViewState
is used to preserve current view data such as loading in progress, data displayed, error displayed, etc. after configuration changes such as device rotation. More details at ViewState- LCE describes Loading-Content-Error flow typical of many Android apps where loading indicator (such as
ProgressBar
) is followed by displaying content or error. - Delegate Callbacks is a set of interfaces that Mosby uses internally which you are welcome to implement yourself instead of inheriting from base MVP classes. For instance, instead of extending
MvpActivity
, implementMvpDelegateCallback
or instead of extendingMvpViewStateController
implementMvpViewStateConductorDelegateCallback
and so forth. MvpNullObjectBasePresenter
is a special kind of Presenter which implements the Null Object Pattern. It makes it unnecessary for you to check if the View is attached prior to calling methods on it. Any calls on the View that is not attached will do nothing (no op); no NullPointerExceptions will be thrown.MvpQueuingBasePresenter
is a special kind of Presenter which lets you queue the calls on the View and replay them in same order once the View becomes available.
All examples implement MVP pattern
- Hello World
- Simple Hello World sample. [link]
- Hello World with ViewState
- Hello World with
ViewState
preserved across configuration changes. [link]
- Hello World with
- LCE pull-to-refresh with ViewState
- Todo-style notes screen using RecyclerView with
ViewState
preserved across configuration changes. [link]
- Todo-style notes screen using RecyclerView with
- Mosby Conductor Hello World
- Mosby with Conductor plugin sample. [link]
- Mosby Conductor Hello World with ViewState
- Mosby with Conductor plugin with
ViewState
preserved across configuration changes. [link]
- Mosby with Conductor plugin with
- Mosby Conductor LCE pull-to-refresh with ViewState
- Mosby with Conductor plugin LCE pull-to-refresh with
ViewState
preserved across configuration changes. [link]
- Mosby with Conductor plugin LCE pull-to-refresh with
- Mosby Conductor Dagger Sample
Copyright 2017 James Shvarts
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.