An MVP Boilerplate to save users having to create the same project over from scratch every time! :)
This project uses RxJava 2.0 and Retrofit 2.0 for networking purposes. It uses Room database fro persistence. It uses Picasso for displayiong images. It uses Lombok plugin to auto generate getters and setters. It uses Crashlytics to report crashes that happens anywhere in the production directly to your email Id. It uses com.android.support:design to support recyclerView, snackbars, and etc.
MVP stands for Model, View, Presenter. It can also include Interactor(For more segregation).
MVP is used to write good Unit testable code. Unit testable code is written by segregating Views, Business logic, database and network operations.
Presenters:
Presenters are the middleman for model and interactors.
Interactors:
Interactors are the ones that are responsible for network operations.
It is found inside the "main" package under "modules" section. (File Path : app -> java -> com.thbs.mis.baseboilerplateandroid -> modules -> main)
- clone the project.
- Change the package name. :
Note :
If you face any problems after renaming the package, Please refer this link : https://stackoverflow.com/questions/26888762/after-renaming-package-name-in-android-studio-launching-error-runtime-error
-
Make sure you create new modules under "modules" package(As of now, in this project, there is a module by the name "main" - which simply means main module).
-
All the modules must have contract, interactor, presenter, model, and view packages.
i). contract package will have an interface which in turn will have 3 other interfaces bundled in it, namely, View, Presenter, Interactor. All interfaces have to be extended from its base. For eg: View has to extend from BaseView, Presenter has to extend from BasePresenter, and Interactor has to extends from BaseInteractor.
ii). interactor package will have all the interactors. All the interactors must have to implement its contract.Interactor interface. For eg: ProductInteractor will implement ProductContract.Interactor.
iii). presenter package will have all the presenters. All the presenters must have to implement its contract.Presenter interface. For eg: ProductPresenter will implement ProductContract.Presenter.
iv). model package will have all the models.
v). view package will have all the activities, fragments and adapters.
a) all the activities will extend BaseActivity and will implement its contract.View interface. For eg: ProductActivity will extend BaseActivity and will implement ProductContract.View. b) all the fragments will extend BaseFragment and will implement its contract.View interface. For eg: ProductActivity will extend BaseFragment and will implement ProductContract.View.
- Base classes for Activities, Adapters, Fragments.
- Base interfaces to implement in Views, Presenters and Interactors.
- Few UTIL classes that are required.