Skip to content

Instantly share code, notes, and snippets.

@enginebai
Created September 13, 2020 23:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save enginebai/a419d2f558ada1b96991365b8760f9a5 to your computer and use it in GitHub Desktop.
Save enginebai/a419d2f558ada1b96991365b8760f9a5 to your computer and use it in GitHub Desktop.
MovieHunt blog part3. repo modified
interface MovieRepo {
fun fetchMovieList(category: MovieCategory, pageSize: Int = DEFAULT_PAGE_SIZE): Listing<MovieModel>
}
class MovieRepoImpl : MovieRepo, KoinComponent {
override fun fetchMovieList(
category: MovieCategory,
pageSize: Int
): Listing<MovieModel> {
val dataSourceFactory = MovieListDataSourceFactory(category)
val pagedListConfig = PagedList.Config.Builder()
.setPageSize(DEFAULT_PAGE_SIZE)
.setEnablePlaceholders(false)
.build()
val pagedList = RxPagedListBuilder(dataSourceFactory, pagedListConfig)
.setFetchScheduler(Schedulers.io())
.buildObservable()
return Listing(
pagedList = pagedList,
refreshState = dataSourceFactory.initLoadState,
loadMoreState = dataSourceFactory.loadMoreState,
refresh = { dataSourceFactory.dataSource?.invalidate() }
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment