This repository contains the SimpleViralGames Assignment App, built using Kotlin and Jetpack Compose. The app generates random images of dogs and saves them in a persistent cache for later viewing.
- Buttons:
- Generate Dogs: Navigate to the Generate Dogs screen.
- Recently Generated Dogs: Navigate to the gallery of cached dog images.
- Generate Button:
- Fetches a random dog image from the Dog CEO API.
- Displays the fetched image.
- Stores the image in an LRU cache (limited to 20 images).
- Cache is persisted using RoomDB, ensuring images are saved across app sessions.
- Scrollable Gallery:
- Displays cached dog images in a gallery view.
- Clear Dogs Button:
- Clears the cache and the gallery view.
- Kotlin
- Jetpack Compose
- RoomDB for data persistence.
- MVVM Architecture for code organization.
- LRU Cache for managing image storage.
- Retrofit for API requests.
- Coroutines for asynchronous operations.
-
Home Screen:
- Acts as the main hub, providing navigation options to the other two screens.
-
Generate Dogs Screen:
- The "Generate!" button triggers an API request to fetch a random dog image.
- The fetched image is displayed and added to the LRU cache.
- The cache is implemented with a size limit of 20 images, ensuring memory efficiency.
- Data is persisted using RoomDB to retain images across app sessions.
-
Recently Generated Dogs Screen:
- Displays all cached images in a scrollable gallery.
- The "Clear Dogs" button clears the RoomDB cache and the gallery.