Project Overview
App for listing users via remote API developed with the purpose of studies and focused on the use of the Paging Library 3 library to implement paging.
The project was developed using the simple paging strategy of remote source only (webservice) and remote source + local (network + database) with RemoteMediator
.
The strategies implemented were separated into 2 branches: paging_source
and remote_mediator
.
Simple Paging
When paging directly from the network, the PagingSource
loads the data and returns a LoadResult
object. The implementation of the PagingSource
is passed to the Pager
using the parameter pagingSourceFactory
.
As new data is required by the UI, Pager
calls the load()
method of the PagingSource
and returns a stream of PagingData
that encapsulate the new data. Typically, each PagingData
object is cached in the ViewModel
before being sent to the UI for display.
Remote Mediator
An implementation of RemoteMediator
helps load paged data from the network into the database, but does not load data directly into the UI. Instead, the app uses the database as the source of truth, that is, the app only shows data that has been cached in the database. An implementation of PagingSource
(generated by Room
) handles loading cached data from the database into the UI.