Application is developed for listing images from Shutterstock with a smooth endless scrolling experience. Users can search and preview images throught the application via Shutterstock's content. Application developed for Android platform with Kotlin programming language on MVVM Architecture.
Before running this application, developer must declare 2 variables in order to fetch images from Shutterstock Developers
gradle.properties
- API_CONSUMER_KEY="consumer_key"
- API_CONSUMER_SECRET="consumer_secret"
The structure of the project is based on the Google Android Architecture
- The project architecture is Model-View-ViewModel (MVVM) pattern.
- Views will inform the ViewModel of user interactions.
- ViewModels have the responsibility of the communication with the views through reactive events. They also handle the logic with the data needed for the views.
- The project uses native Android ViewModel, it allows data to survive configuration changes such as screen rotations.
- LiveData is used for handling communication between activities/fragments and ViewModels through events.
- Dependency Injection (Dagger2) is used on the project for using singleton instances to prevent memory allocation for unnecessary classes/objects, to make network requests to Shutterstock API, make communication easy between classes.
- Kotlin: App language
https://kotlinlang.org/ - Android Jetpack: Collection of Android software components to make development easiersuch as ViewModel, LiveData, AndroidX design components etc. https://developer.android.com/jetpack/androidx/
- ConstraintLayout: To arrange grid images by their width and height ratios https://developer.android.com/jetpack/androidx/
- RxJava2: Reactive programming library
https://github.com/ReactiveX/RxJava - Dagger2: Framework for dependencies injection
https://github.com/google/dagger - Retrofit: REST API communication http://square.github.io/retrofit/
- OkHttp: HTTP+HTTP/2 client http://square.github.io/retrofit/
- Picasso: Image Loading
http://square.github.io/picasso/
I have chosen MVVM Architecture for;
- Better Separation of Concerns
- The MVVM pattern presents a better separation of concerns by adding view models to the mix. The view model translates the data of the model layer into something the view layer can use. The fragment or activity is no longer responsible for this task.
- Improved Testability
- Activities/Fragments are notoriously hard to test because of their relation to the view layer. By migrating data manipulation to the view model, testing becomes much easier. Testing view models is easy. Because a view model doesn’t have a reference to the object it is owned by, it easy to write unit tests for a view model.
- Transparent Communication The responsibilities of the fragment are reduced to controlling the interaction between the view layer and the model layer, glueing both layers together. The view model provides a transparant interface to the view controller, which it uses to populate the view layer and interact with the model layer.
The project has InfiniteScrollListener class for handling endless scroll events. I might use the Paging library to consume data from the rest api. I didn't want to use it because of it's complexity and not to create a lot of boilerplate code just to handle paging.