From 7798523ad1d142611758ab22914e552a74d1b1b2 Mon Sep 17 00:00:00 2001 From: Matthieu <24-artectrex@users.noreply.shinice.net> Date: Fri, 22 Jan 2021 19:42:56 +0100 Subject: [PATCH] use max instead of min_id --- .../feeds/uncachedFeeds/profile/ProfilePagingSource.kt | 8 ++++---- .../main/java/com/h/pixeldroid/utils/api/PixelfedAPI.kt | 3 ++- app/src/main/res/layout/activity_profile.xml | 1 + build.gradle | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/h/pixeldroid/posts/feeds/uncachedFeeds/profile/ProfilePagingSource.kt b/app/src/main/java/com/h/pixeldroid/posts/feeds/uncachedFeeds/profile/ProfilePagingSource.kt index c351205c..fba34d11 100644 --- a/app/src/main/java/com/h/pixeldroid/posts/feeds/uncachedFeeds/profile/ProfilePagingSource.kt +++ b/app/src/main/java/com/h/pixeldroid/posts/feeds/uncachedFeeds/profile/ProfilePagingSource.kt @@ -10,20 +10,20 @@ class ProfilePagingSource( private val api: PixelfedAPI, private val accessToken: String, private val accountId: String -) : PagingSource() { - override suspend fun load(params: LoadParams): LoadResult { +) : PagingSource() { + override suspend fun load(params: LoadParams): LoadResult { 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) diff --git a/app/src/main/java/com/h/pixeldroid/utils/api/PixelfedAPI.kt b/app/src/main/java/com/h/pixeldroid/utils/api/PixelfedAPI.kt index 6a7b45e2..cbbda235 100644 --- a/app/src/main/java/com/h/pixeldroid/utils/api/PixelfedAPI.kt +++ b/app/src/main/java/com/h/pixeldroid/utils/api/PixelfedAPI.kt @@ -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 diff --git a/app/src/main/res/layout/activity_profile.xml b/app/src/main/res/layout/activity_profile.xml index cc907bbe..0beccd4c 100644 --- a/app/src/main/res/layout/activity_profile.xml +++ b/app/src/main/res/layout/activity_profile.xml @@ -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" diff --git a/build.gradle b/build.gradle index 1b6312c6..efd6d745 100644 --- a/build.gradle +++ b/build.gradle @@ -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