enginebai / AndroidBase

Android project template for Gradle Kotlin DSL + 100% Kotlin + Base module + Extensions = ❤️
https://enginebai.com/2019/10/21/gradle-kotlin-dsl/
MIT License
132 stars 17 forks source link

Paging utils #5

Closed enginebai closed 4 years ago

enginebai commented 4 years ago
enum class NetworkState {
    IDLE,
    LOADING,
    ERROR
}

/**
 * It is used for UI to show a list and corresponding states and actions.
 */
data class Listing<T>(
    // the paged list for UI to observe
    val pagedList: Observable<PagedList<T>>,
    // the network request state for pull-to-refresh or first time refresh
    val refreshState: Observable<NetworkState>? = null,
    // the network request state to show progress or error
    val loadMoreState: Observable<NetworkState>? = null,
    // refresh the whole data set and fetch it from scatch
    val refresh: () -> Unit = {}
)