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

View File

@ -208,7 +208,8 @@ interface PixelfedAPI {
suspend fun accountPosts( suspend fun accountPosts(
@Header("Authorization") authorization: String, @Header("Authorization") authorization: String,
@Path("id") account_id: 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 @Query("limit") limit: Int
) : List<Status> ) : List<Status>

View File

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

View File

@ -7,7 +7,7 @@ buildscript {
jcenter() jcenter()
} }
dependencies { 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" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong // NOTE: Do not place your application dependencies here; they belong