Browse posts and search posts are now available in anonymous mode.

This commit is contained in:
Alex Ning 2019-08-09 16:57:04 +08:00
parent 17fc426ecb
commit 1179cb50fa
9 changed files with 190 additions and 54 deletions

View File

@ -77,12 +77,21 @@ class AccountRecyclerViewAdapter extends RecyclerView.Adapter<AccountRecyclerVie
holder.usernameTextView.setText(R.string.add_account); holder.usernameTextView.setText(R.string.add_account);
holder.itemView.setOnClickListener(view -> mItemSelectedListener.addAccountSelected()); holder.itemView.setOnClickListener(view -> mItemSelectedListener.addAccountSelected());
} else if(position == mAccounts.size() + 1) { } else if(position == mAccounts.size() + 1) {
if(mCurrentAccountName != null) {
holder.profileImageGifImageView.setColorFilter(ContextCompat.getColor(mContext, R.color.primaryTextColor), android.graphics.PorterDuff.Mode.SRC_IN); holder.profileImageGifImageView.setColorFilter(ContextCompat.getColor(mContext, R.color.primaryTextColor), android.graphics.PorterDuff.Mode.SRC_IN);
mGlide.load(R.drawable.ic_outline_public_24px) mGlide.load(R.drawable.ic_outline_public_24px)
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(128, 0))) .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(128, 0)))
.into(holder.profileImageGifImageView); .into(holder.profileImageGifImageView);
holder.usernameTextView.setText(R.string.anonymous_account); holder.usernameTextView.setText(R.string.anonymous_account);
holder.itemView.setOnClickListener(view -> mItemSelectedListener.anonymousSelected()); holder.itemView.setOnClickListener(view -> mItemSelectedListener.anonymousSelected());
} else {
holder.profileImageGifImageView.setColorFilter(ContextCompat.getColor(mContext, R.color.primaryTextColor), android.graphics.PorterDuff.Mode.SRC_IN);
mGlide.load(R.drawable.ic_outline_settings_24px)
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(128, 0)))
.into(holder.profileImageGifImageView);
holder.usernameTextView.setText(R.string.manage_accounts);
holder.itemView.setOnClickListener(view -> mItemSelectedListener.manageAccountSelected());
}
} else if(position == mAccounts.size() + 2) { } else if(position == mAccounts.size() + 2) {
holder.profileImageGifImageView.setColorFilter(ContextCompat.getColor(mContext, R.color.primaryTextColor), android.graphics.PorterDuff.Mode.SRC_IN); holder.profileImageGifImageView.setColorFilter(ContextCompat.getColor(mContext, R.color.primaryTextColor), android.graphics.PorterDuff.Mode.SRC_IN);
mGlide.load(R.drawable.ic_outline_settings_24px) mGlide.load(R.drawable.ic_outline_settings_24px)
@ -90,7 +99,7 @@ class AccountRecyclerViewAdapter extends RecyclerView.Adapter<AccountRecyclerVie
.into(holder.profileImageGifImageView); .into(holder.profileImageGifImageView);
holder.usernameTextView.setText(R.string.manage_accounts); holder.usernameTextView.setText(R.string.manage_accounts);
holder.itemView.setOnClickListener(view -> mItemSelectedListener.manageAccountSelected()); holder.itemView.setOnClickListener(view -> mItemSelectedListener.manageAccountSelected());
} else if(mCurrentAccountName != null) { } else {
holder.profileImageGifImageView.setColorFilter(ContextCompat.getColor(mContext, R.color.primaryTextColor), android.graphics.PorterDuff.Mode.SRC_IN); holder.profileImageGifImageView.setColorFilter(ContextCompat.getColor(mContext, R.color.primaryTextColor), android.graphics.PorterDuff.Mode.SRC_IN);
mGlide.load(R.drawable.ic_outline_block_24px) mGlide.load(R.drawable.ic_outline_block_24px)
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(128, 0))) .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(128, 0)))
@ -107,7 +116,7 @@ class AccountRecyclerViewAdapter extends RecyclerView.Adapter<AccountRecyclerVie
return 1; return 1;
} else { } else {
if(mCurrentAccountName == null) { if(mCurrentAccountName == null) {
return mAccounts.size() + 3; return mAccounts.size() + 2;
} else { } else {
return mAccounts.size() + 4; return mAccounts.size() + 4;
} }

View File

@ -19,7 +19,7 @@ class FetchPost {
static void fetchPost(Retrofit oauthRetrofit, String id, String accessToken, Locale locale, FetchPostListener fetchPostListener) { static void fetchPost(Retrofit oauthRetrofit, String id, String accessToken, Locale locale, FetchPostListener fetchPostListener) {
RedditAPI api = oauthRetrofit.create(RedditAPI.class); RedditAPI api = oauthRetrofit.create(RedditAPI.class);
Call<String> postCall = api.getPost(id, RedditUtils.getOAuthHeader(accessToken)); Call<String> postCall = api.getPostOauth(id, RedditUtils.getOAuthHeader(accessToken));
postCall.enqueue(new Callback<String>() { postCall.enqueue(new Callback<String>() {
@Override @Override
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) { public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {

View File

@ -297,8 +297,13 @@ public class MainActivity extends AppCompatActivity implements SortTypeBottomShe
loadUserData(); loadUserData();
mAccountNameTextView.setText(mAccountName); if(mAccessToken != null) {
mKarmaTextView.setText(getString(R.string.karma_info, mKarma)); mKarmaTextView.setText(getString(R.string.karma_info, mKarma));
mAccountNameTextView.setText(mAccountName);
} else {
mKarmaTextView.setText(R.string.press_here_to_login);
mAccountNameTextView.setText(R.string.anonymous_account);
}
if (mProfileImageUrl != null && !mProfileImageUrl.equals("")) { if (mProfileImageUrl != null && !mProfileImageUrl.equals("")) {
glide.load(mProfileImageUrl) glide.load(mProfileImageUrl)
@ -516,6 +521,30 @@ public class MainActivity extends AppCompatActivity implements SortTypeBottomShe
@NonNull @NonNull
@Override @Override
public Fragment getItem(int position) { public Fragment getItem(int position) {
if(mAccessToken == null) {
if(position == 0) {
PostFragment fragment = new PostFragment();
Bundle bundle = new Bundle();
bundle.putInt(PostFragment.EXTRA_POST_TYPE, PostDataSource.TYPE_SUBREDDIT);
bundle.putString(PostFragment.EXTRA_NAME, "popular");
bundle.putString(PostFragment.EXTRA_SORT_TYPE, PostDataSource.SORT_TYPE_HOT);
bundle.putInt(PostFragment.EXTRA_FILTER, PostFragment.EXTRA_NO_FILTER);
bundle.putString(PostFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
fragment.setArguments(bundle);
return fragment;
} else {
PostFragment fragment = new PostFragment();
Bundle bundle = new Bundle();
bundle.putInt(PostFragment.EXTRA_POST_TYPE, PostDataSource.TYPE_SUBREDDIT);
bundle.putString(PostFragment.EXTRA_NAME, "all");
bundle.putString(PostFragment.EXTRA_SORT_TYPE, PostDataSource.SORT_TYPE_HOT);
bundle.putInt(PostFragment.EXTRA_FILTER, PostFragment.EXTRA_NO_FILTER);
bundle.putString(PostFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
fragment.setArguments(bundle);
return fragment;
}
}
if (position == 0) { if (position == 0) {
PostFragment fragment = new PostFragment(); PostFragment fragment = new PostFragment();
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
@ -619,6 +648,13 @@ public class MainActivity extends AppCompatActivity implements SortTypeBottomShe
} }
void changeSortType(String sortType) { void changeSortType(String sortType) {
if(mAccessToken == null) {
if(viewPager.getCurrentItem() == 0) {
popularPostFragment.changeSortType(sortType);
} else {
allPostFragment.changeSortType(sortType);
}
} else {
switch (viewPager.getCurrentItem()) { switch (viewPager.getCurrentItem()) {
case 0: case 0:
frontPagePostFragment.changeSortType(sortType); frontPagePostFragment.changeSortType(sortType);
@ -630,8 +666,20 @@ public class MainActivity extends AppCompatActivity implements SortTypeBottomShe
allPostFragment.changeSortType(sortType); allPostFragment.changeSortType(sortType);
} }
} }
}
public void refresh() { public void refresh() {
if(mAccessToken == null) {
if(viewPager.getCurrentItem() == 0) {
if(popularPostFragment != null) {
((FragmentCommunicator) popularPostFragment).refresh();
}
} else {
if(allPostFragment != null) {
((FragmentCommunicator) allPostFragment).refresh();
}
}
} else {
switch (viewPager.getCurrentItem()) { switch (viewPager.getCurrentItem()) {
case 0: case 0:
if(frontPagePostFragment != null) { if(frontPagePostFragment != null) {
@ -651,3 +699,4 @@ public class MainActivity extends AppCompatActivity implements SortTypeBottomShe
} }
} }
} }
}

View File

@ -53,8 +53,8 @@ class PostDataSource extends PageKeyedDataSource<String, Post> {
this.retrofit = retrofit; this.retrofit = retrofit;
this.accessToken = accessToken; this.accessToken = accessToken;
this.locale = locale; this.locale = locale;
paginationNetworkStateLiveData = new MutableLiveData(); paginationNetworkStateLiveData = new MutableLiveData<>();
initialLoadStateLiveData = new MutableLiveData(); initialLoadStateLiveData = new MutableLiveData<>();
hasPostLiveData = new MutableLiveData<>(); hasPostLiveData = new MutableLiveData<>();
this.postType = postType; this.postType = postType;
this.sortType = sortType; this.sortType = sortType;
@ -284,7 +284,13 @@ class PostDataSource extends PageKeyedDataSource<String, Post> {
private void loadSubredditPostsInitial(@NonNull final LoadInitialCallback<String, Post> callback, String lastItem) { private void loadSubredditPostsInitial(@NonNull final LoadInitialCallback<String, Post> callback, String lastItem) {
RedditAPI api = retrofit.create(RedditAPI.class); RedditAPI api = retrofit.create(RedditAPI.class);
Call<String> getPost = api.getSubredditBestPosts(subredditOrUserName, sortType, lastItem, RedditUtils.getOAuthHeader(accessToken));
Call<String> getPost;
if(accessToken == null) {
getPost = api.getSubredditBestPosts(subredditOrUserName, sortType, lastItem);
} else {
getPost = api.getSubredditBestPostsOauth(subredditOrUserName, sortType, lastItem, RedditUtils.getOAuthHeader(accessToken));
}
getPost.enqueue(new Callback<String>() { getPost.enqueue(new Callback<String>() {
@Override @Override
public void onResponse(@NonNull Call<String> call, @NonNull retrofit2.Response<String> response) { public void onResponse(@NonNull Call<String> call, @NonNull retrofit2.Response<String> response) {
@ -356,7 +362,14 @@ class PostDataSource extends PageKeyedDataSource<String, Post> {
String after = lastItem == null ? params.key : lastItem; String after = lastItem == null ? params.key : lastItem;
RedditAPI api = retrofit.create(RedditAPI.class); RedditAPI api = retrofit.create(RedditAPI.class);
Call<String> getPost = api.getSubredditBestPosts(subredditOrUserName, sortType, after, RedditUtils.getOAuthHeader(accessToken));
Call<String> getPost;
if(accessToken == null) {
getPost = api.getSubredditBestPosts(subredditOrUserName, sortType, after);
} else {
getPost = api.getSubredditBestPostsOauth(subredditOrUserName, sortType, after, RedditUtils.getOAuthHeader(accessToken));
}
getPost.enqueue(new Callback<String>() { getPost.enqueue(new Callback<String>() {
@Override @Override
public void onResponse(@NonNull Call<String> call, @NonNull retrofit2.Response<String> response) { public void onResponse(@NonNull Call<String> call, @NonNull retrofit2.Response<String> response) {
@ -394,7 +407,13 @@ class PostDataSource extends PageKeyedDataSource<String, Post> {
private void loadUserPostsInitial(@NonNull final LoadInitialCallback<String, Post> callback, String lastItem) { private void loadUserPostsInitial(@NonNull final LoadInitialCallback<String, Post> callback, String lastItem) {
RedditAPI api = retrofit.create(RedditAPI.class); RedditAPI api = retrofit.create(RedditAPI.class);
Call<String> getPost = api.getUserBestPosts(subredditOrUserName, lastItem, RedditUtils.getOAuthHeader(accessToken));
Call<String> getPost;
if(accessToken == null) {
getPost = api.getUserBestPosts(subredditOrUserName, lastItem);
} else {
getPost = api.getUserBestPostsOauth(subredditOrUserName, lastItem, RedditUtils.getOAuthHeader(accessToken));
}
getPost.enqueue(new Callback<String>() { getPost.enqueue(new Callback<String>() {
@Override @Override
public void onResponse(@NonNull Call<String> call, @NonNull retrofit2.Response<String> response) { public void onResponse(@NonNull Call<String> call, @NonNull retrofit2.Response<String> response) {
@ -447,7 +466,13 @@ class PostDataSource extends PageKeyedDataSource<String, Post> {
String after = lastItem == null ? params.key : lastItem; String after = lastItem == null ? params.key : lastItem;
RedditAPI api = retrofit.create(RedditAPI.class); RedditAPI api = retrofit.create(RedditAPI.class);
Call<String> getPost = api.getUserBestPosts(subredditOrUserName, after, RedditUtils.getOAuthHeader(accessToken));
Call<String> getPost;
if(accessToken == null) {
getPost = api.getUserBestPosts(subredditOrUserName, after);
} else {
getPost = api.getUserBestPostsOauth(subredditOrUserName, after, RedditUtils.getOAuthHeader(accessToken));
}
getPost.enqueue(new Callback<String>() { getPost.enqueue(new Callback<String>() {
@Override @Override
public void onResponse(@NonNull Call<String> call, @NonNull retrofit2.Response<String> response) { public void onResponse(@NonNull Call<String> call, @NonNull retrofit2.Response<String> response) {
@ -488,9 +513,18 @@ class PostDataSource extends PageKeyedDataSource<String, Post> {
Call<String> getPost; Call<String> getPost;
if(subredditOrUserName == null) { if(subredditOrUserName == null) {
getPost = api.searchPosts(query, null, sortType, RedditUtils.getOAuthHeader(accessToken)); if(accessToken == null) {
getPost = api.searchPosts(query, lastItem, sortType);
} else { } else {
getPost = api.searchPostsInSpecificSubreddit(subredditOrUserName, query, null, RedditUtils.getOAuthHeader(accessToken)); getPost = api.searchPostsOauth(query, lastItem, sortType, RedditUtils.getOAuthHeader(accessToken));
}
} else {
if(accessToken == null) {
getPost = api.searchPostsInSpecificSubreddit(subredditOrUserName, query, lastItem);
} else {
getPost = api.searchPostsInSpecificSubredditOauth(subredditOrUserName, query, lastItem,
RedditUtils.getOAuthHeader(accessToken));
}
} }
getPost.enqueue(new Callback<String>() { getPost.enqueue(new Callback<String>() {
@ -548,9 +582,17 @@ class PostDataSource extends PageKeyedDataSource<String, Post> {
Call<String> getPost; Call<String> getPost;
if(subredditOrUserName == null) { if(subredditOrUserName == null) {
getPost = api.searchPosts(query, after, sortType, RedditUtils.getOAuthHeader(accessToken)); if(accessToken == null) {
getPost = api.searchPosts(query, after, sortType);
} else { } else {
getPost = api.searchPostsInSpecificSubreddit(subredditOrUserName, query, after, RedditUtils.getOAuthHeader(accessToken)); getPost = api.searchPostsOauth(query, after, sortType, RedditUtils.getOAuthHeader(accessToken));
}
} else {
if(accessToken == null) {
getPost = api.searchPostsInSpecificSubreddit(subredditOrUserName, query, after);
} else {
getPost = api.searchPostsInSpecificSubredditOauth(subredditOrUserName, query, after, RedditUtils.getOAuthHeader(accessToken));
}
} }
getPost.enqueue(new Callback<String>() { getPost.enqueue(new Callback<String>() {

View File

@ -200,8 +200,13 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
} }
}); });
if(accessToken == null) {
factory = new PostViewModel.Factory(mRetrofit, accessToken,
getResources().getConfiguration().locale, subredditName, query, postType, sortType, filter);
} else {
factory = new PostViewModel.Factory(mOauthRetrofit, accessToken, factory = new PostViewModel.Factory(mOauthRetrofit, accessToken,
getResources().getConfiguration().locale, subredditName, query, postType, sortType, filter); getResources().getConfiguration().locale, subredditName, query, postType, sortType, filter);
}
} else if(postType == PostDataSource.TYPE_SUBREDDIT) { } else if(postType == PostDataSource.TYPE_SUBREDDIT) {
String subredditName = getArguments().getString(EXTRA_NAME); String subredditName = getArguments().getString(EXTRA_NAME);
@ -224,8 +229,13 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
} }
}); });
if(accessToken == null) {
factory = new PostViewModel.Factory(mRetrofit, accessToken,
getResources().getConfiguration().locale, subredditName, postType, sortType, filter);
} else {
factory = new PostViewModel.Factory(mOauthRetrofit, accessToken, factory = new PostViewModel.Factory(mOauthRetrofit, accessToken,
getResources().getConfiguration().locale, subredditName, postType, sortType, filter); getResources().getConfiguration().locale, subredditName, postType, sortType, filter);
}
} else if(postType == PostDataSource.TYPE_USER) { } else if(postType == PostDataSource.TYPE_USER) {
CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) mFetchPostInfoLinearLayout.getLayoutParams(); CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) mFetchPostInfoLinearLayout.getLayoutParams();
params.height = ViewGroup.LayoutParams.WRAP_CONTENT; params.height = ViewGroup.LayoutParams.WRAP_CONTENT;
@ -251,8 +261,13 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
} }
}); });
if(accessToken == null) {
factory = new PostViewModel.Factory(mRetrofit, accessToken,
getResources().getConfiguration().locale, username, postType, sortType, filter);
} else {
factory = new PostViewModel.Factory(mOauthRetrofit, accessToken, factory = new PostViewModel.Factory(mOauthRetrofit, accessToken,
getResources().getConfiguration().locale, username, postType, sortType, filter); getResources().getConfiguration().locale, username, postType, sortType, filter);
}
} else { } else {
mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit, redditDataRoomDatabase, mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit, redditDataRoomDatabase,
accessToken, postType, true, new PostRecyclerViewAdapter.Callback() { accessToken, postType, true, new PostRecyclerViewAdapter.Callback() {

View File

@ -39,19 +39,29 @@ public interface RedditAPI {
Call<String> voteThing(@HeaderMap Map<String, String> headers, @FieldMap Map<String, String> params); Call<String> voteThing(@HeaderMap Map<String, String> headers, @FieldMap Map<String, String> params);
@GET("comments/{id}.json?raw_json=1") @GET("comments/{id}.json?raw_json=1")
Call<String> getPost(@Path("id") String id, @HeaderMap Map<String, String> headers); Call<String> getPostOauth(@Path("id") String id, @HeaderMap Map<String, String> headers);
@GET("comments/{id}.json?raw_json=1")
Call<String> getPost(@Path("id") String id);
@GET("{sortType}?raw_json=1") @GET("{sortType}?raw_json=1")
Call<String> getBestPosts(@Path("sortType") String sortType, @Query("after") String lastItem, @HeaderMap Map<String, String> headers); Call<String> getBestPosts(@Path("sortType") String sortType, @Query("after") String lastItem, @HeaderMap Map<String, String> headers);
@GET("r/{subredditName}/{sortType}.json?raw_json=1&limit=25") @GET("r/{subredditName}/{sortType}.json?raw_json=1&limit=25")
Call<String> getSubredditBestPosts(@Path("subredditName") String subredditName, @Path("sortType") String sortType, Call<String> getSubredditBestPostsOauth(@Path("subredditName") String subredditName, @Path("sortType") String sortType,
@Query("after") String lastItem, @HeaderMap Map<String, String> headers); @Query("after") String lastItem, @HeaderMap Map<String, String> headers);
@GET("r/{subredditName}/{sortType}.json?raw_json=1&limit=25")
Call<String> getSubredditBestPosts(@Path("subredditName") String subredditName, @Path("sortType") String sortType,
@Query("after") String lastItem);
@GET("user/{username}/submitted.json?raw_json=1&limit=25") @GET("user/{username}/submitted.json?raw_json=1&limit=25")
Call<String> getUserBestPosts(@Path("username") String username, @Query("after") String lastItem, Call<String> getUserBestPostsOauth(@Path("username") String username, @Query("after") String lastItem,
@HeaderMap Map<String, String> headers); @HeaderMap Map<String, String> headers);
@GET("user/{username}/submitted.json?raw_json=1&limit=25")
Call<String> getUserBestPosts(@Path("username") String username, @Query("after") String lastItem);
@GET("user/{username}/about.json?raw_json=1") @GET("user/{username}/about.json?raw_json=1")
Call<String> getUserData(@Path("username") String username); Call<String> getUserData(@Path("username") String username);
@ -72,12 +82,19 @@ public interface RedditAPI {
Call<String> searchUsers(@Query("q") String profileName, @Query("after") String after, @Query("sort") String sort); Call<String> searchUsers(@Query("q") String profileName, @Query("after") String after, @Query("sort") String sort);
@GET("search.json?raw_json=1&type=link&include_over_18=on") @GET("search.json?raw_json=1&type=link&include_over_18=on")
Call<String> searchPosts(@Query("q") String query, @Query("after") String after, @Query("sort") String sort, Call<String> searchPostsOauth(@Query("q") String query, @Query("after") String after, @Query("sort") String sort,
@HeaderMap Map<String, String> headers); @HeaderMap Map<String, String> headers);
@GET("search.json?raw_json=1&type=link&include_over_18=on")
Call<String> searchPosts(@Query("q") String query, @Query("after") String after, @Query("sort") String sort);
@GET("r/{subredditName}/search.json?raw_json=1&type=link&restrict_sr=true&include_over_18=on")
Call<String> searchPostsInSpecificSubredditOauth(@Path("subredditName") String subredditName, @Query("q") String query,
@Query("after") String after, @HeaderMap Map<String, String> headers);
@GET("r/{subredditName}/search.json?raw_json=1&type=link&restrict_sr=true&include_over_18=on") @GET("r/{subredditName}/search.json?raw_json=1&type=link&restrict_sr=true&include_over_18=on")
Call<String> searchPostsInSpecificSubreddit(@Path("subredditName") String subredditName, @Query("q") String query, Call<String> searchPostsInSpecificSubreddit(@Path("subredditName") String subredditName, @Query("q") String query,
@Query("after") String after, @HeaderMap Map<String, String> headers); @Query("after") String after);
@FormUrlEncoded @FormUrlEncoded
@POST("api/comment") @POST("api/comment")
@ -102,7 +119,10 @@ public interface RedditAPI {
Call<String> getRules(@Path("subredditName") String subredditName); Call<String> getRules(@Path("subredditName") String subredditName);
@GET("/comments/{id}.json?raw_json=1") @GET("/comments/{id}.json?raw_json=1")
Call<String> getPostAndCommentsById(@Path("id") String id, @HeaderMap Map<String, String> headers); Call<String> getPostAndCommentsByIdOauth(@Path("id") String id, @HeaderMap Map<String, String> headers);
@GET("/comments/{id}.json?raw_json=1")
Call<String> getPostAndCommentsById(@Path("id") String id);
@Multipart @Multipart
@POST(".") @POST(".")

View File

@ -439,7 +439,7 @@ class SubmitPost {
RedditAPI api = oauthRetrofit.create(RedditAPI.class); RedditAPI api = oauthRetrofit.create(RedditAPI.class);
Call<String> getPostCall = api.getPost(postId, RedditUtils.getOAuthHeader(accessToken)); Call<String> getPostCall = api.getPostOauth(postId, RedditUtils.getOAuthHeader(accessToken));
getPostCall.enqueue(new Callback<String>() { getPostCall.enqueue(new Callback<String>() {
@Override @Override
public void onResponse(@NonNull Call<String> call, @NonNull retrofit2.Response<String> response) { public void onResponse(@NonNull Call<String> call, @NonNull retrofit2.Response<String> response) {

View File

@ -201,7 +201,7 @@ public class ViewPostDetailActivity extends AppCompatActivity {
.getString(SharedPreferencesUtils.ACCESS_TOKEN_KEY, ""); .getString(SharedPreferencesUtils.ACCESS_TOKEN_KEY, "");
RedditAPI api = mOauthRetrofit.create(RedditAPI.class); RedditAPI api = mOauthRetrofit.create(RedditAPI.class);
Call<String> postAndComments = api.getPostAndCommentsById(subredditId, RedditUtils.getOAuthHeader(accessToken)); Call<String> postAndComments = api.getPostAndCommentsByIdOauth(subredditId, RedditUtils.getOAuthHeader(accessToken));
postAndComments.enqueue(new Callback<String>() { postAndComments.enqueue(new Callback<String>() {
@Override @Override
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) { public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {

View File

@ -176,4 +176,5 @@
<string name="anonymous_account">Anonymous</string> <string name="anonymous_account">Anonymous</string>
<string name="manage_accounts">Manage accounts</string> <string name="manage_accounts">Manage accounts</string>
<string name="log_out">Log out</string> <string name="log_out">Log out</string>
<string name="press_here_to_login">Press here to login</string>
</resources> </resources>