Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/skbhati199/android-mvvm
Android Assignment
https://github.com/skbhati199/android-mvvm
android kotlin-android livedata mvvm-architecture
Last synced: about 1 month ago
JSON representation
Android Assignment
- Host: GitHub
- URL: https://github.com/skbhati199/android-mvvm
- Owner: skbhati199
- Created: 2023-05-02T18:22:19.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2023-05-02T18:22:23.000Z (over 1 year ago)
- Last Synced: 2024-12-20T15:27:58.695Z (about 1 month ago)
- Topics: android, kotlin-android, livedata, mvvm-architecture
- Language: Kotlin
- Homepage:
- Size: 110 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Android Assignment Readme
This Android assignment is a machine test that involves implementing the following:- Retrieving data from an API endpoint using Retrofit client
- Displaying the data in a RecyclerView using MVVM design pattern and data binding
- Using Picasso library for image rendering
- Writing unit test cases for the implemented code
## Technologies used
- Kotlin programming language
- Android Studio IDE
- Retrofit for API calls
- Koin for dependency injection
- MVVM design pattern
- Data binding and View binding
- Picasso library for image rendering
- JUnit and Mockito for unit testing
## API endpoint
The API endpoint used in this assignment is `https://jsonplaceholder.typicode.com/photos.` It returns a JSON array of photo objects.## Implementation
The implementation of this assignment consists of the following components:- MainActivity: The main activity of the application. It hosts the PhotoListFragment.
- PhotoListFragment: This fragment retrieves data from the API endpoint using Retrofit and displays it in a RecyclerView using data binding. It uses the ViewModel and LiveData classes to retrieve and store the data respectively.
- PhotoRepository: This repository class retrieves data from the API endpoint using Retrofit and returns it to the ViewModel.
- PhotoViewModel: This ViewModel class retrieves data from the PhotoRepository and stores it in a LiveData object.
- NetworkModule: This module provides a Retrofit client instance using Dagger Hilt.
- AppModule: This module provides instances of the Picasso library and the PhotoRepository using Dagger Hilt.
PhotoDetailsFragment: This fragment displays details of a photo item including a header image, title, and description. It uses the Navigation component to navigate from the PhotoListFragment to the PhotoDetailsFragment passing the selected photo item data.
- PhotoDetailsViewModel: This ViewModel class retrieves the selected photo item data from the Navigation arguments and provides it to the PhotoDetailsFragment for display.## Unit testing
The implemented code has unit tests written for it. The unit tests include testing the ViewModel, Repository, and API calls. The tests use the JUnit and Mockito libraries.
## Conclusion
This assignment has been implemented using MVVM design pattern, Retrofit, Dagger Hilt, data binding, and Picasso library. Unit tests have been written using JUnit and Mockito.