diff options
Diffstat (limited to 'app/src/main')
-rw-r--r-- | app/src/main/java/ml/docilealligator/infinityforreddit/apis/RedditAPI.java | 13 | ||||
-rw-r--r-- | app/src/main/java/ml/docilealligator/infinityforreddit/post/PostPagingSource.java | 4 |
2 files changed, 11 insertions, 6 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/apis/RedditAPI.java b/app/src/main/java/ml/docilealligator/infinityforreddit/apis/RedditAPI.java index 9db3669e..78bb8bb4 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/apis/RedditAPI.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/apis/RedditAPI.java @@ -5,6 +5,7 @@ import com.google.common.util.concurrent.ListenableFuture; import java.util.Map; import ml.docilealligator.infinityforreddit.SortType; +import ml.docilealligator.infinityforreddit.utils.APIUtils; import okhttp3.MultipartBody; import okhttp3.RequestBody; import retrofit2.Call; @@ -15,6 +16,7 @@ import retrofit2.http.Field; import retrofit2.http.FieldMap; import retrofit2.http.FormUrlEncoded; import retrofit2.http.GET; +import retrofit2.http.Header; import retrofit2.http.HeaderMap; import retrofit2.http.Multipart; import retrofit2.http.POST; @@ -282,10 +284,13 @@ public interface RedditAPI { ListenableFuture<Response<String>> getSubredditBestPostsListenableFuture(@Path("subredditName") String subredditName, @Path("sortType") SortType.Type sortType, @Query("t") SortType.Time sortTime, @Query("after") String lastItem); - @GET("user/{username}/{where}.json?&type=links&raw_json=1&limit=100") - ListenableFuture<Response<String>> getUserPostsOauthListenableFuture(@Path("username") String username, @Path("where") String where, - @Query("after") String lastItem, @Query("sort") SortType.Type sortType, - @Query("t") SortType.Time sortTime, @HeaderMap Map<String, String> headers); + @GET("user/{username}/{where}.json?type=links&raw_json=1&limit=100") + ListenableFuture<Response<String>> getUserPostsOauthListenableFuture(@Header(APIUtils.AUTHORIZATION_KEY) String authorization, + @Path("username") String username, + @Path("where") String where, + @Query("after") String lastItem, + @Query("sort") SortType.Type sortType, + @Query("t") SortType.Time sortTime); @GET("user/{username}/submitted.json?raw_json=1&limit=100") ListenableFuture<Response<String>> getUserPostsListenableFuture(@Path("username") String username, @Query("after") String lastItem, diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/post/PostPagingSource.java b/app/src/main/java/ml/docilealligator/infinityforreddit/post/PostPagingSource.java index 2d5191a4..7c256d59 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/post/PostPagingSource.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/post/PostPagingSource.java @@ -257,8 +257,8 @@ public class PostPagingSource extends ListenableFuturePagingSource<String, Post> userPosts = api.getUserPostsListenableFuture(subredditOrUserName, loadParams.getKey(), sortType.getType(), sortType.getTime()); } else { - userPosts = api.getUserPostsOauthListenableFuture(subredditOrUserName, userWhere, loadParams.getKey(), sortType.getType(), - sortType.getTime(), APIUtils.getOAuthHeader(accessToken)); + userPosts = api.getUserPostsOauthListenableFuture(APIUtils.AUTHORIZATION_BASE + accessToken, + subredditOrUserName, userWhere, loadParams.getKey(), sortType.getType(), sortType.getTime()); } ListenableFuture<LoadResult<String, Post>> pageFuture = Futures.transform(userPosts, this::transformData, executor); |