Picsum Photo App
The app’s functionality includes:
- Fetch a list of images from picsum photos api (https://picsum.photos/) and show them in
StaggeredGrid Layout Manager.
- User can view the list of images using smooth infinite scroll.
- When an image is selected from
RecyclerViewit will load the full-screen image with pinch zoom in/out feature.
- User can download the image from full-screen view.
- User can share the image from full-screen view.
- The image list is cached into local DB, so the list of images are available offline.
- The app supports
RecyclerViewcontent from remote source.
The app uses clean architecture with
MVVM(Model View View Model) design pattern.
MVVM provides better separation of concern, easier testing, Live data & lifecycle awareness, etc.
The UI consists of two screen
MainActivity.kt– Initial screen. Shows a list of images.
FullScreenActivity.kt– Shows full-screen view of the image with additional options.
Model is generated from
JSON data into a Kotlin data class.
In addition, entity class has been added for room database.
Used for fetching picsum images & update livedata. Also send out the status of the network call like Loading, Success, Error using
Used for downloading the image into a bitmap & save it into internal storage.
The app uses
Dagger-hilt as a dependency injection library.
ApplicationModule.kt class provides
Singleton reference for
The network layer is composed of Repository, ApiService.
PicsumApi – Is an interface containing the suspend functions for retrofit API call.
ImageListRepository – Holds the definition of the remote/local repository call.
You can open the project in Android studio and press run.
Android Studio version used to build the project: Arctic fox 2020.3.1
Gradle plugin used in the project will require
Java 11.0 to run.
you can set the gradle jdk in
Preferences->Build Tools->Gradle->Gradle JDK
- Android appcompat, core, constraint layout, Material Support.
- Android View Binding
Hiltfor dependency injection
Retrofitfor REST API communication
Coroutinefor Network call
Roomfor local database.
Glidefor image loading.
Custom fileproviderfor writing & reading files into internal storage.
Swipe Refresh Layoutfor pull-to-refresh
Junitfor Unit testing.
Robolectricfor Instrumentation testing
Truthfor Assertion in testing.
Photo Viewfor zoom in/out image.
Unit and integration testing has been added for
Test the viewmodel of the app using
The test cases comprise of testing different states like Loading, Success, Error with fake data for testing image list response, cache response.
Test Image donwload returns file uri & URL to bitmap conversion.
Test the Repository of the app using
The test comprises of testing the functionality of Image Room Database like Insertion, Remove, Get saved response etc.
Mock Webserver is used to test the Network api response in case of successful data, empty, failed case.
|Infinite Scroll, Pinch Zoom||Image Download||Image share|