Last active
June 14, 2018 13:04
-
-
Save Marchuck/e2ad5d5bbccb16d7fda6e6bfeafb4b54 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SwapiPeoplePagedListProvider(private val factory: DataSource.Factory<Int, Person?>) : PagedListProvider<Person?> { | |
override fun provide(): LiveData<PagedList<Person?>> { | |
return LivePagedListBuilder(factory, PagedList.Config.Builder() | |
.setEnablePlaceholders(false) | |
.setPageSize(20) | |
.setInitialLoadSizeHint(20) | |
.build() | |
).setFetchExecutor(createFetchExecutor()) | |
.build() | |
} | |
private fun createFetchExecutor(): ExecutorService { | |
val threads = Runtime.getRuntime().availableProcessors() + 1 | |
return Executors.newFixedThreadPool(threads) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment