Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/njleonzhang/android-mvvm-boilerplate
Android MVVM boilerplate inspired by android-boilerplate and powered by data-binding
https://github.com/njleonzhang/android-mvvm-boilerplate
Last synced: 7 days ago
JSON representation
Android MVVM boilerplate inspired by android-boilerplate and powered by data-binding
- Host: GitHub
- URL: https://github.com/njleonzhang/android-mvvm-boilerplate
- Owner: njleonzhang
- Created: 2017-06-20T03:25:27.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-09-30T09:08:57.000Z (about 6 years ago)
- Last Synced: 2024-04-15T04:37:57.740Z (7 months ago)
- Language: Java
- Homepage:
- Size: 387 KB
- Stars: 26
- Watchers: 1
- Forks: 11
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Android-MVVM-boilerplate
Android MVVM boilerplate inspired by [android-boilerplate](https://github.com/ribot/android-boilerplate) and powered by [data-binding](https://developer.android.com/topic/libraries/data-binding/index.html)## Archetcture
![](https://cdn.rawgit.com/njleonzhang/Android-MVVM-boilerplate/master/assets/archtecure.png)It's similar to [android-boilerplate](https://github.com/ribot/android-boilerplate#architecture), differences:
* `Presenter` to `ViewModel`
* `EventBus` to `RxBus`
* `shareReferenceHelper` is not proxied by data manager, but a static tools.## Tech-stack
* Data-Binding
* RxJava2
* Retrofit2
* OKHttp## Code Organization
![](https://cdn.rawgit.com/njleonzhang/Android-MVVM-boilerplate/master/assets/code_organization.png)* binding —> binding adapters for databinding
* data —> Model(network, database)
* ui —> View and ViewModel(ui and business logic)
* util —> common tools
* widget —> common widget## UML
![](https://cdn.rawgit.com/njleonzhang/Android-MVVM-boilerplate/master/assets/uml2.png)
---
![](https://cdn.rawgit.com/njleonzhang/Android-MVVM-boilerplate/master/assets/uml1.png)
---
![](https://cdn.rawgit.com/njleonzhang/Android-MVVM-boilerplate/master/assets/uml3.png)## Details
### MVC / MVP / MVVM
We support all 3 in this project.
* Some page is simple, With MVVM, you need create at least 2 new files(class), With MVP, you need more files(class), why not just adopt MVC?
* Someone in your team, does not love MVVM, and used to work in MVP. OK, **Forced love does not last**.
* For all 3 architectures, Activity and Fragment are wrapped and easy to initialize.Check [base](https://github.com/njleonzhang/Android-MVVM-boilerplate/tree/master/app/src/main/java/com/leon/mvvm/ui/base) folder for more details.
### NetWork
Leverage `Retrofit2` and `RxJava2` to parse response and handle error(including loading) in common place, we just deal with data in business logic.Check [DataManager](https://github.com/njleonzhang/Android-MVVM-boilerplate/blob/master/app/src/main/java/com/leon/mvvm/data/DataManager.java) for more details
### recycle view binding
No need to write adapter agian and agian, with data-binding and [BaseBindingRecycleViewAdapter](https://github.com/njleonzhang/Android-MVVM-boilerplate/blob/master/app/src/main/java/com/leon/mvvm/utils/BaseBindingRecycleViewAdapter.java), we just need provide a layout file and the array of data, then we get a recycleView### RxBus
Leverage `Rxjava` to post none-sticky event, no need to override any Activity method, and really easy and clean to use.Check [RxBus](https://github.com/njleonzhang/Android-MVVM-boilerplate/blob/master/app/src/main/java/com/leon/mvvm/utils/RxBus.java) for more details.