Simple Android Boilerplate

Download From Github

I have created the simple Android MVP Boilerplate

For POJO Models use : http://www.jsonschema2pojo.org/

Requirements

You can – Download Example to see how it’s working

or You can use with gradle or maven as below dependencies

For Gradle

Step 1.

Add it in your root build.gradle at the end of repositories:

allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}

Step 2.

Add the dependency

dependencies {
        compile 'com.github.manishkpr:manishkprsimpleboilerplate:v1.0.6'
}

For Maven

Step 1.

Add the JitPack repository to your build file

<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>

Step 2.

Add the dependency

<dependency>
    <groupId>com.github.manishkpr</groupId>
    <artifactId>manishkprsimpleboilerplate</artifactId>
    <version>v1.0.6</version>
</dependency>

How to implement a new screen following MVP

Imagine you have to implement a sign in screen.

  1. Create a new package under ui called signin
  2. Create an new Activity called ActivitySignIn. You could also use a Fragment.
  3. Define the view interface that your Activity is going to implement. Create a new interface called SignInMvpViewthat extends MvpView. Add the methods that you think will be necessary, e.g. showSignInSuccessful()
  4. Create a SignInPresenter class that extends BasePresenter<SignInMvpView>
  5. 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 call getMvpView().showSignInSuccessful().
  6. Create a SignInPresenterTestand write unit tests for signIn(email). Remember to mock the SignInMvpViewand also the DataManager.
  7. Make your ActivitySignIn implement SignInMvpView and implement the required methods like showSignInSuccessful()
  8. In your activity, inject a new instance of SignInPresenter and call presenter.attachView(this) from onCreateand presenter.detachView() from onDestroy(). Also, set up a click listener in your button that calls presenter.signIn(email).