Created
October 19, 2021 14:28
-
-
Save tunjid/7ddfbde1dcd85fe049540d39853f5dd2 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| override suspend fun load(loadType: LoadType, state: PagingState<Int, Repo>): MediatorResult { | |
| val page = when (loadType) { | |
| LoadType.REFRESH -> … | |
| LoadType.PREPEND -> … | |
| LoadType.APPEND -> … | |
| } | |
| val apiQuery = query + IN_QUALIFIER | |
| try { | |
| val apiResponse = service.searchRepos(apiQuery, page, state.config.pageSize) | |
| val repos = apiResponse.items | |
| val endOfPaginationReached = repos.isEmpty() | |
| repoDatabase.withTransaction { | |
| … | |
| repoDatabase.reposDao().insertAll(repos) | |
| } | |
| return MediatorResult.Success(endOfPaginationReached = endOfPaginationReached) | |
| } catch (exception: IOException) { | |
| return MediatorResult.Error(exception) | |
| } catch (exception: HttpException) { | |
| return MediatorResult.Error(exception) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment