- Check for open issues and feature requests. If there is an issue that you are interested in, leave a comment, and the issue can be assigned to you!
- Join the slack channel hosted here
- Fork a copy of the repository, clone it to your local environment, and open the project in Android Studio!
- Once you finish and commit your changes to your forked repository, open a pull request, attribute the request to the issue that is assigned to you, and submit your changes! We'll review them and accept/decline the changes!
This project uses the standard MVP architecture (Model View Presenter) and was originated from the android-boilerplate project created by the UK company Ribot (Original Repository)
-
View (UI layer): this is where Activities, Fragments and other standard Android components live. It's responsible for displaying the data received from the presenters to the user. It also handles user interactions and inputs (click listeners, etc) and triggers the right action in the Presenter if needed.
-
Presenter: presenters subscribe to RxJava Observables provided by the
DataManager
. They are in charge of handling the subscription lifecycle, analysing/modifying the data returned by theDataManager
and calling the appropriate methods in the View in order to display the data. -
Model (Data Layer): this is responsible for retrieving, saving, caching and massaging data. It can communicate with local databases and other data stores as well as with restful APIs or third party SDKs. It is divided in two parts: a group of helpers and a
DataManager
. The number of helpers vary between project and each of them has a very specific function, e.g. talking to an API or saving data inSharedPreferences
. TheDataManager
combines and transforms the outputs from different helpers using Rx operators so it can: 1) provide meaningful data to the Presenter, 2) group actions that will always happen together. This layer also contains the actual model classes that define how the data structure is.
Here is a diagram of how we implement the MVP architecture (courtesy of ribot)
- Create a new package under
ui
calledsignin
(or whatever screen you are working on) - Create an new Activity called
ActivitySignIn
. You could also use a Fragment. - Define the view interface that your Activity is going to implement. Create a new interface called
SignInMvpView
that extendsMvpView
. Add the methods that you think will be necessary, e.g.showSignInSuccessful()
- Create a
SignInPresenter
class that extendsBasePresenter<SignInMvpView>
- Implement the methods in
SignInPresenter
that your Activity requires to perform the necessary actions, e.g.signIn(String email)
. Once the sign in action finishes you should callgetMvpView().showSignInSuccessful()
. - Create a
SignInPresenterTest
and write unit tests forsignIn(email)
. Remember to mock theSignInMvpView
and also theDataManager
. - Make your
ActivitySignIn
implementSignInMvpView
and implement the required methods likeshowSignInSuccessful()
- In your activity, inject a new instance of
SignInPresenter
and callpresenter.attachView(this)
fromonCreate
andpresenter.detachView()
fromonDestroy()
. Also, set up a click listener in your button that callspresenter.signIn(email)
.