What’s this sample project about?

This application is a Marvel’s characters searching app which is a simple Android client for the Marvel.com. This application was created by me, as a part of the technical assessment by the smava GmbH technical team.

Marvel Android Application screenshot

The app must search character, view information and cache last searches.

This project implemented using MVP and contains modern Android development concepts and libraries which can really change your professional life!

I will try my best to explain everything in different parts of this continues article namely: Dagger, Retrofit, RxJava, and Tests.

The project also had Continues Integration(CI) using Circleci.com & Travis-ci.org and code coverage reports using Codecov.io and also using google new Firebase service which you can study by yourself and it is off topic for this article somehow.

You can get more familiar with the project by reading README and Task files before getting start.

Okay, Show me what you got:

Let’s take a look at the project’s structure.

I personally enjoy working on a clean code, so I really enjoy breaking a project into some meaningful parts that help me and the whole team with keeping more clear with tasks.

Modules:

Project consist of two main and a java console sample modules:

app (marvel-app): Android Application module core-lib (marvel-core): Core Library module console (marvel-console): a java console sample module

The app module contains the Android View layer of MVP, while the other layers (Model & Presentation) are all placed in the core which is pure java and after compile it would be a jar library.

What’s the use of breaking code into modules?!

First of all, separating the Android Application module reminds you that you should not pass Context or any Android related objects to Presenter or Model! …so please stop doing it!!!

or any Android related objects to or Secondly, you can make sure that the core part is that much complete that you can use it with even another UI (namely: Java Console sample, Web Applet or as a prediction even someday in near future an iOS app using java!!)

(namely: Java Console sample, Web Applet or as a prediction even someday in near future an iOS app using java!!) Finally, I and our team really enjoy developing Applications like this! and whole team members benefit from having core apart, and even we put the core in a git submodule and use it in different projects with the same core and different UI.

The result of java console sample module which works the same as Android Application with the core

A little module’s name cleanup:

to make modules look more convenient and nice you can edit settings.gradle file like this:

which gives you this clean look:

and also cause a relevant name for output APK file.

How to avoid version conflicts and redundant in different modules?

using a Gradle feature could come handy for a clean build.gradle file and avoiding version conflicts and redundant in your project’s modules.

First of all, place all your project’s dependencies inside a Gradle file like libraries.gradle:

then add it to your project main build.gradle file (take care of the last line):

and finally, use it like a charm in your app module build.gradle file (take care of dependencies part):

and your core module build.gradle file: