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.
ViewModel
.# 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.