diff options
author | Alex Ning <chineseperson5@gmail.com> | 2019-12-17 10:54:14 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2019-12-17 10:54:14 +0000 |
commit | cdd25f3405b7a41e796507612e83b394a1479d64 (patch) | |
tree | e5cd5311463396edacb29a884c0cc0176c504514 /app/src/main/java/ml | |
parent | cc86e047f0e76303a9afc63b6c80604556a0e241 (diff) | |
download | infinity-for-reddit-cdd25f3405b7a41e796507612e83b394a1479d64.tar infinity-for-reddit-cdd25f3405b7a41e796507612e83b394a1479d64.tar.gz infinity-for-reddit-cdd25f3405b7a41e796507612e83b394a1479d64.tar.bz2 infinity-for-reddit-cdd25f3405b7a41e796507612e83b394a1479d64.tar.lz infinity-for-reddit-cdd25f3405b7a41e796507612e83b394a1479d64.tar.xz infinity-for-reddit-cdd25f3405b7a41e796507612e83b394a1479d64.tar.zst infinity-for-reddit-cdd25f3405b7a41e796507612e83b394a1479d64.zip |
Fixed sort type cannot be changed for multireddit.
Diffstat (limited to 'app/src/main/java/ml')
-rw-r--r-- | app/src/main/java/ml/docilealligator/infinityforreddit/PostDataSource.java | 23 | ||||
-rw-r--r-- | app/src/main/java/ml/docilealligator/infinityforreddit/RedditAPI.java | 16 |
2 files changed, 21 insertions, 18 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/PostDataSource.java b/app/src/main/java/ml/docilealligator/infinityforreddit/PostDataSource.java index 058dbc98..fc207a02 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/PostDataSource.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/PostDataSource.java @@ -68,7 +68,11 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> { if (postType == TYPE_SUBREDDIT) { this.subredditOrUserName = path; } else { - multiRedditPath = path; + if (path.endsWith("/")) { + multiRedditPath = path + sortType.getType().value; + } else { + multiRedditPath = path + "/" + sortType.getType().value; + } } paginationNetworkStateLiveData = new MutableLiveData<>(); initialLoadStateLiveData = new MutableLiveData<>(); @@ -747,17 +751,16 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> { Call<String> getPost; if (accessToken == null) { if (sortType.getTime() != null) { - getPost = api.getMultiRedditPosts(multiRedditPath, lastItem, sortType.getType().value, - sortType.getTime().value); + getPost = api.getMultiRedditPosts(multiRedditPath, lastItem, sortType.getTime().value); } else { - getPost = api.getMultiRedditPosts(multiRedditPath, lastItem, sortType.getType().value); + getPost = api.getMultiRedditPosts(multiRedditPath, lastItem); } } else { if (sortType.getTime() != null) { - getPost = api.getMultiRedditPostsOauth(multiRedditPath, lastItem, sortType.getType().value, + getPost = api.getMultiRedditPostsOauth(multiRedditPath, lastItem, sortType.getTime().value, RedditUtils.getOAuthHeader(accessToken)); } else { - getPost = api.getMultiRedditPostsOauth(multiRedditPath, lastItem, sortType.getType().value, + getPost = api.getMultiRedditPostsOauth(multiRedditPath, lastItem, RedditUtils.getOAuthHeader(accessToken)); } } @@ -817,17 +820,17 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> { Call<String> getPost; if (accessToken == null) { if (sortType.getTime() != null) { - getPost = api.getMultiRedditPosts(multiRedditPath, after, sortType.getType().value, + getPost = api.getMultiRedditPosts(multiRedditPath, after, sortType.getTime().value); } else { - getPost = api.getMultiRedditPosts(multiRedditPath, after, sortType.getType().value); + getPost = api.getMultiRedditPosts(multiRedditPath, after); } } else { if (sortType.getTime() != null) { - getPost = api.getMultiRedditPostsOauth(multiRedditPath, after, sortType.getType().value, + getPost = api.getMultiRedditPostsOauth(multiRedditPath, after, sortType.getTime().value, RedditUtils.getOAuthHeader(accessToken)); } else { - getPost = api.getMultiRedditPostsOauth(multiRedditPath, after, sortType.getType().value, + getPost = api.getMultiRedditPostsOauth(multiRedditPath, after, RedditUtils.getOAuthHeader(accessToken)); } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/RedditAPI.java b/app/src/main/java/ml/docilealligator/infinityforreddit/RedditAPI.java index 73b1df87..848e8807 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/RedditAPI.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/RedditAPI.java @@ -273,19 +273,19 @@ public interface RedditAPI { Call<String> getUserMultiReddits(@Path("username") String username); @GET("{multipath}?raw_json=1") - Call<String> getMultiRedditPosts(@Path(value = "multipath", encoded = true) String multiPath, @Query("after") String after, - @Query("sort") String sortType); + Call<String> getMultiRedditPosts(@Path(value = "multipath", encoded = true) String multiPath, + @Query("after") String after); @GET("{multipath}?raw_json=1") - Call<String> getMultiRedditPosts(@Path(value = "multipath", encoded = true) String multiPath, @Query("after") String after, - @Query("sort") String sortType, @Query("t") String sortTime); + Call<String> getMultiRedditPosts(@Path(value = "multipath", encoded = true) String multiPath, + @Query("after") String after, @Query("t") String sortTime); @GET("{multipath}.json?raw_json=1") - Call<String> getMultiRedditPostsOauth(@Path(value = "multipath", encoded = true) String multiPath, @Query("after") String after, - @Query("sort") String sortType, @Query("t") String sortTime, + Call<String> getMultiRedditPostsOauth(@Path(value = "multipath", encoded = true) String multiPath, + @Query("after") String after, @Query("t") String sortTime, @HeaderMap Map<String, String> headers); @GET("{multipath}.json?raw_json=1") - Call<String> getMultiRedditPostsOauth(@Path(value = "multipath", encoded = true) String multiPath, @Query("after") String after, - @Query("sort") String sortType, @HeaderMap Map<String, String> headers); + Call<String> getMultiRedditPostsOauth(@Path(value = "multipath", encoded = true) String multiPath, + @Query("after") String after, @HeaderMap Map<String, String> headers); } |