I have created the simple Android MVP Boilerplate
[Release Jitpack] (https://jitpack.io/#manishkpr/manishkprsimpleboilerplate)
[For POJO Models use :] (http://www.jsonschema2pojo.org/) http://www.jsonschema2pojo.org/
- JDK 1.8
- Android SDK.
- Android N (API 25) .
- Latest Android SDK Tools and build tools.
You can - [Download Example ] (https://github.com/manishkpr/manishkprsimpleboilerplate/archive/master.zip) to see how it's working
or You can use with gradle or maven as below dependencies
Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Add the dependency
dependencies {
compile 'com.github.manishkpr:manishkprsimpleboilerplate:v1.0.17'
}
Add the JitPack repository to your build file
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Add the dependency
<dependency>
<groupId>com.github.manishkpr</groupId>
<artifactId>manishkprsimpleboilerplate</artifactId>
<version>v1.0.17</version>
</dependency>
Imagine you have to implement a sign in screen.
- Create a new package under
ui
calledsignin
- 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 extendsUiView
. 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)
.