Android Kotlin paged endpoints made easy
The library now has 3 different modules:
These modules are independent and none of them are strictly required. The new dependencies are:
repositories {
maven { url "https://jitpack.io" }
}
dependencies {
// This dependency is required only if you want to use a Retrofit service without a special adapter.
implementation 'com.github.xmartlabs.fountain:fountain-retrofit:0.4.0'
// This dependency is required only if you want to use a Coroutine retrofit adapter.
implementation 'com.github.xmartlabs.fountain:fountain-coroutines:0.4.0'
// This dependency is required only if you want to use a RxJava2 retrofit adapter.
implementation 'com.github.xmartlabs.fountain:fountain-rx2:0.4.0'
}
Although Fountain was designed to work with paged endpoints, it also supports working with not paged endpoints. That means that you can use all [Listing] features in services that return a list that's not paged.
There's one static factory object class for each each dependency.
Each static factory has the same constructors with different params:
createNetworkListing
: A constructor to get a Listing
component from a common paged Retrofit service implementation.createNotPagedNetworkListing
: A constructor to get a Listing
component from a common not paged Retrofit service implementation.createNetworkWithCacheSupportListing
: A constructor to get a Listing
component with cache support from a common paged Retrofit service implementation.createNotPagedNetworkWithCacheSupportListing
: A constructor to get a Listing
component with cache support from a common not paged Retrofit service implementation.If you use either ListResponseWithPageCount
or ListResponseWithEntityCount
you can convert a PageFetcher
to a NetworkDataSourceAdapter
using these extensions:
fun <ServiceResponse : ListResponseWithEntityCount<*>>
PageFetcher<ServiceResponse>.toTotalEntityCountNetworkDataSourceAdapter(firstPage: Int)
fun <ServiceResponse : ListResponseWithPageCount<*>>
PageFetcher<ServiceResponse>.toTotalPageCountNetworkDataSourceAdapter(firstPage: Int)
To more about these changes you can read the full documentation here.
Improve NetworkState
structure #28.
Now that structure has the requested page
number, pageSize
, isFirstPage
, isLastPage
.
Breaking changes:
The NetworkState
data class is replaced by a sealed class
and the Status
enum was removed.
Initial version