Skip to content

Sample Android app that I use as a reference for my new Android projects

Notifications You must be signed in to change notification settings

laanayabdrzak/Android-Boilerplate

Repository files navigation

Android Boilerplate

Sample Android app that I use as a reference for my new Android projects. It demonstrates the architecture, tools and guidelines that I use when developing for the Android platform:

##Third Party Libraries & tools included

Requirements

Good Architecture

  • Clean Architecture is :
    • Independent of UI
    • Independent of Frameworks
    • Independent of any agency externe
    • Independent of Database
    • Testable

Read more here

Architecture

This project follows Android architecture guidelines that are based on MVP (Model View Presenter). Read more about them here.

Project structure

new-structure
├─ library-foobar
├─ app
│  ├─ libs
│  ├─ src
│  │  ├─ androidTest
│  │  │  └─ java
│  │  │     └─ com/abderrazak/recycleviewcardview
│  │  ├─ test
│  │  │  └─ java
│  │  │     └─ com/abderrazak/recycleviewcardview
│  │  └─ main
│  │     ├─ java
│  │     │  └─ com/abderrazak/recycleviewcardview
│  │     ├─ res
│  │     └─ AndroidManifest.xml
│  ├─ build.gradle
│  └─ proguard-rules.pro
├─ build.gradle
└─ settings.gradle

Java packages architecture

abderrazak.com.recycleviewcardview
├─ data
│   ├─ local
│   ├─ model
│   └─ remote
├─ service
├─ ui
│   ├─ main
│   ├─ detail
│   └─ etc..
├─ util
└─ views
    ├─ adapters
    └─ widgets

####Gains and Benefits

By looking at the structure you can already tell what the app is all about (figure above);

  • Higher modularity;
  • Easier code navigation;
  • Higher level of abstraction;
  • Separates both features and layers;
  • More readable and maintainable structure;
  • More cohesion;
  • Much easier to scale;
  • Less chance to accidentally modify unrelated classes or files;
  • Much easier to add or remove application features;
  • And much more reusable modules.

Project & code guidelines

check this

How to implement a new screen following MVP

Imagine you have to implement a main screen.

  1. Create a new package under ui called main.

  2. Create an new Activity called MainActivity. You could also use a Fragment.

  3. Define the view interface that your Activity is going to implement. Create a new interface called MainView. Add the methods that you think will be necessary, e.g. showDialog()

  4. Create a MainPresenterImpl class that implement MainPresenter.Implement the methods in MainPresenter that your Activity requires to perform the necessary actions, e.g. setItems(List<Movie> movieItems).

  5. Create a MainPresenterTest and write unit tests for e.g. setItems(List<Movie> movieItems). Remember to mock the MainView.

  6. Make your MainActivity implement SignInMvpView and implement the required methods like showDialog() In your activity, inject a new instance of MAinPresenter and call presenter = new MainPresenterImpl(this) from onCreate and presenter.onDestroy() from onDestroy(). Also, set up a click listener in your button that calls presenter.sortList().

Some of best practices

Check my post here

TODO #1

  • Implement SQlBrite
  • Add Paralax to thumbnail (Parallax Recycleview)

TODO #2

Include those libraries :

Developed By

Author: Abderrazak LAANAYA

Follow me on LinkedIn

About

Sample Android app that I use as a reference for my new Android projects

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages