Skip to content
Thanh Le edited this page Mar 3, 2016 · 3 revisions

What is Nimble?

Nimble is a small, quick and flexible MVP library for Android.

Why Nimble?

  • Nimble provides simple base classes to implement MVP simple.
  • Nimble is simple has less than 500 lines of code. So it is easy to read and understand. You cat get familiar with it in just 30 minutes.
  • Nimble has well tested code (more than 85% code coverage) so you can confident when using it.
  • Nimble is designed to be flexible. So you can use it any way you. It can be used perfectly with Dagger or you can manage it manually.
  • Nimble provides mechanism to manage the life cycle of the view for you.
  • Nimble provides mechanism to save data when activity/fragment/view is recreated throws Bundle class.

Usage

Nimble has two basic interfaces NimbleView and NimblePresenter. They are base interfaces for ant views and presenters.

You should follow these steps to create a MVP component in your application:

  1. Create a View interface which must extents NimbleView:
public interface MainView extends NimbleView {
    void showUser(User user);
}
  1. Create a Presenter interface which must extent NimblePresenter with View generic like:
public interface MainPresenter extends NimblePresenter<MainView> {
    void getUser();
}
  1. Implement your Presenter which should extent BasePresenter:
public class MainPresenterImpl extends BasePresenter<MainView> implements MainPresenter {
    public void getUser(){
        User user = new User();
        getView().showUser(user);
    }
}
  1. Implement your View which should extent base a Nimble Views such as NimbleActivity and implments your View interface:
public class MainActivity extends NimbleActivity<MainView> implements MainView {
    private MainPresenter presenter;

    @Override
    protected MainPresenter presenter() {
        if(presenter == null){
            presenter = new MainPresenter();
        }
        return presenter;
    }

    void onButtonClicked(){
        presenter().getUser();
    }
}

Example

Twitter: @lenguyenthanh

Clone this wiki locally