frankelot
06/17/2021, 11:28 PMNapa Ram
06/18/2021, 9:50 AMFunkyMuse
06/25/2021, 6:00 PMKV
06/28/2021, 7:57 AMprivate const val STARTING_PAGE_INDEX = 1
class AbsencePagingDataSource(
private val apiProvider: ApiProvider,
private val absenceDataMapper: AbsenceDataMapper,
private val workspaceId: String
) :
PagingSource<Int, AbsenceData>() {
lateinit var response: ListApiResponse<WorkspaceAbsenceResponse>
override suspend fun load(params: LoadParams<Int>): LoadResult<Int, AbsenceData> {
val position = params.key ?: STARTING_PAGE_INDEX
val request = Endpoint.GetWorkspaceAbsence(
workspaceId = workspaceId,
Queries = listOf(
Queries.Paginate(position, 50), -------> SEE URL BELOW
)
)
return try {
apiProvider.api.performRequest<ListApiResponse<WorkspaceAbsenceResponse>>(request).map { listApiResponse ->
response = listApiResponse
}
val endOfPaginationReached = response.data.isEmpty()
LoadResult.Page(
data = absenceDataMapper.mapToDomain(response),
prevKey = if (position == STARTING_PAGE_INDEX) null else position - 1,
nextKey = if (endOfPaginationReached) null else position + 1
)
} catch (exception: IOException) {
LoadResult.Error(exception)
}
}
override fun getRefreshKey(state: PagingState<Int, AbsenceData>): Int? {
return state.anchorPosition?.let { anchorPosition ->
state.closestPageToPosition(anchorPosition)?.prevKey?.plus(1)
?: state.closestPageToPosition(anchorPosition)?.nextKey?.minus(1)
}
}
}
URL/request looks like ->
---------------------------
1. url=<https://PATH/api/v3/workspaces/120/absences?page=1&items=50> ----> 200
2. url=<https://PATH/api/v3/workspaces/120/absences?page=2&items=50> ----> 422
3. url=<https://PATH/api/v3/workspaces/120/absences?page=3&items=50> ----> 422
suhas
07/14/2021, 12:05 PMCicero
07/21/2021, 12:15 PMgzhenjin
07/22/2021, 9:16 AMAaron Waller
07/25/2021, 3:56 PMlateinit property analytics has not been initialized
Vyshas
07/25/2021, 3:58 PMAlexander Suraphel
08/07/2021, 3:20 PMMohamed Ibrahim
08/10/2021, 12:31 PModay
08/10/2021, 3:18 PMK Merle
08/14/2021, 5:46 PMcore
package in your apps and what do you usually put in core package?ursus
08/21/2021, 10:47 PMsuhas
08/22/2021, 10:13 AMcontext
to Presenter in MVP?Will Shelor
08/24/2021, 1:52 AMDhaval Gondaliya
08/24/2021, 7:16 AMursus
08/25/2021, 10:23 PMSmorg
08/26/2021, 8:23 AMStateFlow
behaves), but once that value is consumed, it no longer has any value (until it receives another and the cycle continues).Chuck Stein
08/31/2021, 8:38 PMCicero
09/06/2021, 12:31 PMSlackbot
09/11/2021, 1:32 AMViktor Petrovski
09/16/2021, 3:37 PMBrian Donovan
09/18/2021, 3:51 PMtheapache64
10/05/2021, 12:25 PMursus
10/06/2021, 11:04 PMteddy
10/09/2021, 3:46 AMmartinsumera
10/13/2021, 10:12 AMEmiliano Schiavone
10/13/2021, 11:58 AMDiego
10/28/2021, 12:36 PM