Moxy is Android library based on MVP pattern.
Main idea of using Moxy: What's happened here:
- At View happened action , that is passed to Presenter
- Presenter sends command in ViewState
- Presenter starts async request to Model
- ViewState adds a command in commands queue, and then passes it in View
- View brings itself into a state specified in the command
- Presenter receives result of request from Model
- Presenter sends two commands and in ViewState
- ViewState saves commands and in commads queue and send them in View
- View brings itself into a state specified in the commands and
- New/recreated View attach to existing Presenter
- ViewState sends queue of saved commands to new/recreate View
- New/recreated View brings itself into a state specified in the commands , and
Moxy has a few killer features on other ways:
- Presenter stay alive when Activity recreated(it simplify work with multithreading)
- Automatically restore all what user see when Activity recreated(including dynamic content is added)
- Capability to changes of many Views from one Presenter
You can find the sample project here
For all information check Moxy Wiki
[RU] Moxy — реализация MVP под Android с щепоткой магии
[EN] Android without Lifecycle: MPVsV approach with Moxy
Maven integration:
<dependencies>
<dependency>
<groupId>com.arello-mobile</groupId>
<artifactId>moxy</artifactId>
<version>0.5.4</version>
</dependency>
<dependency>
<groupId>com.arello-mobile</groupId>
<artifactId>moxy-android</artifactId>
<version>0.5.4</version>
</dependency>
<dependency>
<groupId>com.arello-mobile</groupId>
<artifactId>moxy-compiler</artifactId>
<version>0.5.4</version>
<optional>true</optional>
</dependency>
</dependencies>
Gradle integration:
dependencies {
...
compile 'com.arello-mobile:moxy:0.5.4'
compile 'com.arello-mobile:moxy-android:0.5.4'
provided 'com.arello-mobile:moxy-compiler:0.5.4'
}
In order to avoid boilerplate code creating for binding activity,fragments and its presentation part, we propose to use Android Studio templates for Moxy.
Templates located in /moxy-templates
The MIT License (MIT)
Copyright (c) 2016 Arello Mobile
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.