Merge branch 'nextKey_fix' into 'master'
Make sure not to send twice the same key for subsequent pages Closes #293 See merge request pixeldroid/PixelDroid!361
This commit is contained in:
commit
120118bfc0
|
@ -56,7 +56,7 @@ class FollowersPagingSource(
|
||||||
LoadResult.Page(
|
LoadResult.Page(
|
||||||
data = accounts,
|
data = accounts,
|
||||||
prevKey = null,
|
prevKey = null,
|
||||||
nextKey = if (accounts.isEmpty() or nextPosition.isEmpty()) null else nextPosition
|
nextKey = if (accounts.isEmpty() || nextPosition.isEmpty() || nextPosition == position) null else nextPosition
|
||||||
)
|
)
|
||||||
} catch (exception: IOException) {
|
} catch (exception: IOException) {
|
||||||
LoadResult.Error(exception)
|
LoadResult.Error(exception)
|
||||||
|
|
|
@ -25,10 +25,12 @@ class HashTagPagingSource(
|
||||||
max_id = position,
|
max_id = position,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
val nextKey = response.lastOrNull()?.id
|
||||||
|
|
||||||
LoadResult.Page(
|
LoadResult.Page(
|
||||||
data = response,
|
data = response,
|
||||||
prevKey = null,
|
prevKey = null,
|
||||||
nextKey = response.lastOrNull()?.id
|
nextKey = if(nextKey == position) null else nextKey
|
||||||
)
|
)
|
||||||
} catch (exception: HttpException) {
|
} catch (exception: HttpException) {
|
||||||
LoadResult.Error(exception)
|
LoadResult.Error(exception)
|
||||||
|
|
|
@ -20,10 +20,12 @@ class ProfilePagingSource(
|
||||||
limit = params.loadSize
|
limit = params.loadSize
|
||||||
)
|
)
|
||||||
|
|
||||||
|
val nextKey = posts.lastOrNull()?.id
|
||||||
|
|
||||||
LoadResult.Page(
|
LoadResult.Page(
|
||||||
data = posts,
|
data = posts,
|
||||||
prevKey = null,
|
prevKey = null,
|
||||||
nextKey = posts.lastOrNull()?.id
|
nextKey = if(nextKey == position) null else nextKey
|
||||||
)
|
)
|
||||||
} catch (exception: HttpException) {
|
} catch (exception: HttpException) {
|
||||||
LoadResult.Error(exception)
|
LoadResult.Error(exception)
|
||||||
|
|
|
@ -34,10 +34,12 @@ class SearchPagingSource<T: FeedContent>(
|
||||||
Results.SearchType.statuses -> response.statuses
|
Results.SearchType.statuses -> response.statuses
|
||||||
} as List<T>
|
} as List<T>
|
||||||
|
|
||||||
|
val nextKey = if (repos.isEmpty()) null else (position ?: 0) + repos.size
|
||||||
|
|
||||||
LoadResult.Page(
|
LoadResult.Page(
|
||||||
data = repos,
|
data = repos,
|
||||||
prevKey = null,
|
prevKey = null,
|
||||||
nextKey = if (repos.isEmpty()) null else (position ?: 0) + repos.size
|
nextKey = if(nextKey == position) null else nextKey
|
||||||
)
|
)
|
||||||
} catch (exception: HttpException) {
|
} catch (exception: HttpException) {
|
||||||
LoadResult.Error(exception)
|
LoadResult.Error(exception)
|
||||||
|
|
Loading…
Reference in New Issue