Quotes application built to demonstrate Pagination using Jetpack Paging library with Remote Mediator following MVVM architecture
Download and test latest version 👇
App loads quotes from open source quotations API Quotable. Uses Paging 3 library for pagination with RemoteMediator for offline support.
A RemoteMediator implementation helps load paged data from the network into the database, but doesn't load data directly into the UI. Instead, the app uses the database as the source of truth.
App follows clean architecture pattern (MVVM). Whole app is organized with intent to create architecture like in multi-module approach.
- Kotlin - First class and official programming language for Android development.
- Coroutines - A coroutine is a concurrency design pattern that you can use on Android to simplify code that executes asynchronously.
- Flow - A flow is an asynchronous version of a Sequence, a type of collection whose values are lazily produced.
- Android Jetpack - A suite of libraries to help developers follow best practices, reduce boilerplate code.
- LiveData - Data objects that notify views when the underlying database changes.
- ViewModel - Stores UI-related data that isn't destroyed on UI changes.
- ViewBinding - Generates a binding class for each XML layout file present in that module and allows you to more easily write code that interacts with views.
- Room - SQLite object mapping library.
- Paging 3 - Paging library helps you load and display pages of data from a larger dataset from local storage or over network.
- DataStore - Jetpack DataStore is a data storage solution that allows you to store key-value pairs or typed objects with protocol buffers. DataStore uses Kotlin coroutines and Flow to store data asynchronously, consistently, and transactionally
- Dependency Injection -
- Hilt-Dagger - Standard library to incorporate Dagger dependency injection into an Android application.
- Hilt-ViewModel - DI for injecting
ViewModel
.
- Retrofit - A type-safe HTTP client for Android and Java.
- Figma - Figma is a browser-based UI and UX design application, with excellent design, prototyping, and code options.
# Root Package
|
├── data # For data handling.
│ ├── local # Local Persistence Database. Room (SQLite) database
| │ ├── dao # Data Access Object for Room
| | |── database # Datbase Instance
| |── remote # Remote Data Handlers
| | ├── dto # Model class from api response
│ | ├── api # Retrofit API for remote end point
| |── mapper # Mapper class to map dto object to required object
| |── paging # Remote mediator class
| |── preference # Datastore manager class
| └── repository # Repository implementation
|
├── domain # Responsible for business logic
| └── repository # Repository interface (Single source of data)
|
├── di # Dependency injection modules
|
├── model # Model/entity classes
|
├── ui # Presentation layer
│ |── App # Application class
| ├── MainActivity # Main activity
| ├── viewmodel # Common viewmodel for all data
| ├── quote # Fragment + PagingDataAdapter + Loader adapter for quotes list
| ├── favorite # Fragment + adapter for favorite quotes
| └── detail # Fragment for detail view of a single quote
|
└── utils # Utility classes
This app uses MVVM (Model View View-Model) architecture and uses RemoteMediator to get page from network and database.