Created
September 17, 2017 12:39
-
-
Save brainail/b071c15264e05f7aed0539c32402a40a to your computer and use it in GitHub Desktop.
Base datasource for Kitsu items
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
abstract class KitsuLimitOffsetNetworkDataSource<T> protected constructor( | |
val dataProvider: KitsuRestApi) : TiledDataSource<T>() { | |
var queryFilter: String = "" | |
override fun countItems(): Int = DataSource.COUNT_UNDEFINED | |
protected abstract fun convertToItems(items: KitsuResponse, size: Int): List<T> | |
override fun loadRange(startPosition: Int, loadCount: Int): List<T>? { | |
val response = dataProvider.getKitsu(queryFilter, startPosition, loadCount).execute().body() | |
return convertToItems(response, response.data.size) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment