Skip to content

Instantly share code, notes, and snippets.

@sharmadhiraj
Created August 3, 2018 06:58
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 sharmadhiraj/cbae4ae5d0e76b748a9c7d0690c71e00 to your computer and use it in GitHub Desktop.
Save sharmadhiraj/cbae4ae5d0e76b748a9c7d0690c71e00 to your computer and use it in GitHub Desktop.
Android Paging Library
class NewsDataSourceFactory(
private val compositeDisposable: CompositeDisposable,
private val networkService: NetworkService)
: DataSource.Factory<Int, News>() {
val newsDataSourceLiveData = MutableLiveData<NewsDataSource>()
override fun create(): DataSource<Int, News> {
val newsDataSource = NewsDataSource(networkService, compositeDisposable)
newsDataSourceLiveData.postValue(newsDataSource)
return newsDataSource
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment