Fixed sort type cannot be changed for multireddit.

This commit is contained in:
Alex Ning 2019-12-17 18:54:14 +08:00
parent cc86e047f0
commit cdd25f3405
2 changed files with 21 additions and 18 deletions

View File

@ -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));
}
}

View File

@ -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);
}