use max instead of min_id

This commit is contained in:
Matthieu 2021-01-22 19:42:56 +01:00
parent b221808f9c
commit 7798523ad1
4 changed files with 8 additions and 6 deletions

View File

@ -10,20 +10,20 @@ class ProfilePagingSource(
private val api: PixelfedAPI,
private val accessToken: String,
private val accountId: String
) : PagingSource<Int, Status>() {
override suspend fun load(params: LoadParams<Int>): LoadResult<Int, Status> {
) : PagingSource<String, Status>() {
override suspend fun load(params: LoadParams<String>): LoadResult<String, Status> {
val position = params.key
return try {
val posts = api.accountPosts("Bearer $accessToken",
account_id = accountId,
min_id = position?.toString(),
max_id = position,
limit = params.loadSize
)
LoadResult.Page(
data = posts,
prevKey = null,
nextKey = posts.lastOrNull()?.id?.toIntOrNull()
nextKey = posts.lastOrNull()?.id
)
} catch (exception: IOException) {
LoadResult.Error(exception)

View File

@ -208,7 +208,8 @@ interface PixelfedAPI {
suspend fun accountPosts(
@Header("Authorization") authorization: String,
@Path("id") account_id: String,
@Query("min_id") min_id: String?,
@Query("min_id") min_id: String? = null,
@Query("max_id") max_id: String?,
@Query("limit") limit: Int
) : List<Status>

View File

@ -125,6 +125,7 @@
android:id="@+id/fragment_profile_feed"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:nestedScrollingEnabled="false"
tools:context=".profile.ProfileFeedFragment"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"

View File

@ -7,7 +7,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.1'
classpath 'com.android.tools.build:gradle:4.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong