Skip to content

acristescu/GreenfieldTemplate

Repository files navigation

Greenfield Template (RxJava 2 version)

BuddyBuild Build status

This is a template that I use for new projects. It already has some basic stuff setup, such as:

  • Retrofit + OKHttp
  • RxJava2
  • Dagger2
  • MVP architecture
  • Kotlin extensions
  • JUnit tests (with Mockito)
  • UI tests with Espresso (run on mockDebug variant!)
  • Mock and connected variants (for offline work and tests)
  • Permission dispatcher library
  • CI Integration (Microsoft's AppCenter) that runs the tests on commit

The app itself connects to Flickr and displays a list of images. You can search for particular tags or you can sort the images.

TODO:

  • maybe have an MVI version?
  • try out mosby for MVP boilerplate?
  • maybe do some cool stuff with Groupie?
  • Koin instead of Dagger?
  • Move more towards Clean Architecture.

Note: I wrote a blog post about an old version of this architecture. It is now obsolete, but the article might be interesting for historic reasons. Remember EventBus? :)

Overview

Here is the diagram of the architecture proposed here:

The flow of events and data:

  1. The Activity reacts to the user input by informing the Presenter that data is required.
  2. The Presenter fires off the appropriate request in the service layer (and instructs the Activity to display a busy indicator).
  3. The Service then issues the correct REST call to the Retrofit layer.
  4. The Retrofit layer exchanges HTTP requests and responses with the Server and returns an Observable (or perhaps Single).
  5. The Service possibly inspects the Observable, schedules it on the correct thread (in order to keep the Presenter free of Android Schedulers and thus pure JUnit testable) and returns it back to the Presenter.
  6. The Presenter receives the Observable, retrieves the data or error and issues the correct commands to the Activity to update the UI (and dismiss the busy indicator).
  7. The Activity presents the user with the data or error message.

Releases

No releases published

Packages

No packages published

Languages