🤖
Test Android Senior Leboncoin Mathieu EDET
Overview
Min API version : 24
This application is designed to display list of songs (fetched from remote JSON at runtime).
{
"id": Int,
"albumId": Int,
"title": String,
"url": String,
"thumbnailUrl": String
}
It was not specified what to do with albumId
, I decide to make a "details" view with selected song title and all associated songs of the album. An index has been added on albumId field to make requests faster
Data is stored locally on database for an offline usage and to be displayed faster at app runtime when remote data is not fetched yet. Image are cached too with Glide.
The single source of truth is database.
Main dependencies selection
For data persistence I have chose to use Room. This ORM provides an abstraction layer over SQLite to allow database data access easily. Its configuration is done via annotations to our persisted entities. Room allows database schema versionning via migrations (not implemented on this test). SQLite queries has to be write manually but there is compile time verification.
For HTTP requests, I have chose Retrofit2 (with http client OkHttp). Developed by Square, it's a own type-safe HTTP library with a big community. This lib seems to be the better one for REST APIs. It can be configured with custom converter : gson on my test (a Java serialization/deserialization library developped by Google), provides good performances to deserialize JSON data.
Image caching : Glide is an image loading library. Google is owner of this one and recommand to use it. It provides great performances for a simple usage.
Additionnally, I use data binding for cleaner fragments / activities and simplify update. Databinding/viewmodel are really efficients together.
Notes
I use product behavior to separate differents environment (there is only one env on this test, but we could have few environment later) with configuration for each one. For now, I store asset root url on this one. I use this product flavor to add prefix to application name and version (simplify environment switching and test on a same device).
If you have any question about this project, please send me a message : [email protected]