Use the proper retrofit object to save comments

This commit fixes the issue with saving comments. It used the old, oauth Retrofit object, instead of our retrofit holder objects. Closes issue #14
This commit is contained in:
Balazs Toldi 2023-07-28 07:45:12 +02:00
parent 6eb585800f
commit 497f6c79d2
No known key found for this signature in database
GPG Key ID: 6C7D440036F99D58
7 changed files with 30 additions and 30 deletions

View File

@ -468,7 +468,7 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
}); });
} else { } else {
comment.setSaved(true); comment.setSaved(true);
saveComment.saveThing(mOauthRetrofit, mAccessToken, comment.getId(), new SaveThing.SaveThingListener() { saveComment.saveThing(mRetrofit.getRetrofit(), mAccessToken, comment.getId(), new SaveThing.SaveThingListener() {
@Override @Override
public void success() { public void success() {
ViewPostDetailFragment fragment = sectionsPagerAdapter.getCurrentFragment(); ViewPostDetailFragment fragment = sectionsPagerAdapter.getCurrentFragment();

View File

@ -77,7 +77,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
} }
}; };
private BaseActivity mActivity; private BaseActivity mActivity;
private Retrofit mOauthRetrofit; private Retrofit retrofit;
private Locale mLocale; private Locale mLocale;
private Markwon mMarkwon; private Markwon mMarkwon;
private RecyclerView.RecycledViewPool recycledViewPool; private RecyclerView.RecycledViewPool recycledViewPool;
@ -110,7 +110,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
String accountName, RetryLoadingMoreCallback retryLoadingMoreCallback) { String accountName, RetryLoadingMoreCallback retryLoadingMoreCallback) {
super(DIFF_CALLBACK); super(DIFF_CALLBACK);
mActivity = activity; mActivity = activity;
mOauthRetrofit = oauthRetrofit; retrofit = oauthRetrofit;
mCommentColor = customThemeWrapper.getCommentColor(); mCommentColor = customThemeWrapper.getCommentColor();
int commentSpoilerBackgroundColor = mCommentColor | 0xFF000000; int commentSpoilerBackgroundColor = mCommentColor | 0xFF000000;
mLocale = locale; mLocale = locale;
@ -537,7 +537,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
comment.getScore() + comment.getVoteType())); comment.getScore() + comment.getVoteType()));
VoteThing.votePost(mActivity, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingListener() { VoteThing.votePost(mActivity, retrofit, mAccessToken, new VoteThing.VoteThingListener() {
@Override @Override
public void onVoteThingSuccess(int position1) { public void onVoteThingSuccess(int position1) {
int currentPosition = getBindingAdapterPosition(); int currentPosition = getBindingAdapterPosition();
@ -607,7 +607,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
comment.getScore() + comment.getVoteType())); comment.getScore() + comment.getVoteType()));
VoteThing.votePost(mActivity, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingListener() { VoteThing.votePost(mActivity, retrofit, mAccessToken, new VoteThing.VoteThingListener() {
@Override @Override
public void onVoteThingSuccess(int position1) { public void onVoteThingSuccess(int position1) {
int currentPosition = getBindingAdapterPosition(); int currentPosition = getBindingAdapterPosition();
@ -650,7 +650,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
SaveComment saveComment = new SaveComment(); SaveComment saveComment = new SaveComment();
if (comment.isSaved()) { if (comment.isSaved()) {
comment.setSaved(false); comment.setSaved(false);
saveComment.unsaveThing(mOauthRetrofit, mAccessToken, comment.getId(), new SaveThing.SaveThingListener() { saveComment.unsaveThing(retrofit, mAccessToken, comment.getId(), new SaveThing.SaveThingListener() {
@Override @Override
public void success() { public void success() {
comment.setSaved(false); comment.setSaved(false);
@ -671,7 +671,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
}); });
} else { } else {
comment.setSaved(true); comment.setSaved(true);
saveComment.saveThing(mOauthRetrofit, mAccessToken, comment.getId(), new SaveThing.SaveThingListener() { saveComment.saveThing(retrofit, mAccessToken, comment.getId(), new SaveThing.SaveThingListener() {
@Override @Override
public void success() { public void success() {
comment.setSaved(true); comment.setSaved(true);

View File

@ -1570,7 +1570,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
}); });
} else { } else {
comment.setSaved(true); comment.setSaved(true);
saveComment.saveThing(mOauthRetrofit, mAccessToken, comment.getId(), new SaveThing.SaveThingListener() { saveComment.saveThing(mRetrofit, mAccessToken, comment.getId(), new SaveThing.SaveThingListener() {
@Override @Override
public void success() { public void success() {
comment.setSaved(true); comment.setSaved(true);

View File

@ -141,7 +141,7 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
private SharedPreferences mSharedPreferences; private SharedPreferences mSharedPreferences;
private SharedPreferences mCurrentAccountSharedPreferences; private SharedPreferences mCurrentAccountSharedPreferences;
private Executor mExecutor; private Executor mExecutor;
private Retrofit mOauthRetrofit; private Retrofit retrofit;
private Retrofit mGfycatRetrofit; private Retrofit mGfycatRetrofit;
private Retrofit mRedgifsRetrofit; private Retrofit mRedgifsRetrofit;
private Provider<StreamableAPI> mStreamableApiProvider; private Provider<StreamableAPI> mStreamableApiProvider;
@ -237,7 +237,7 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
mSharedPreferences = sharedPreferences; mSharedPreferences = sharedPreferences;
mCurrentAccountSharedPreferences = currentAccountSharedPreferences; mCurrentAccountSharedPreferences = currentAccountSharedPreferences;
mExecutor = executor; mExecutor = executor;
mOauthRetrofit = oauthRetrofit; retrofit = oauthRetrofit;
mGfycatRetrofit = gfycatRetrofit; mGfycatRetrofit = gfycatRetrofit;
mRedgifsRetrofit = redgifsRetrofit; mRedgifsRetrofit = redgifsRetrofit;
mStreamableApiProvider = streambleApiProvider; mStreamableApiProvider = streambleApiProvider;
@ -2327,7 +2327,7 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType())); scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType()));
} }
VoteThing.votePost(mActivity, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingListener() { VoteThing.votePost(mActivity, retrofit, mAccessToken, new VoteThing.VoteThingListener() {
@Override @Override
public void onVoteThingSuccess(int position1) { public void onVoteThingSuccess(int position1) {
int currentPosition = getBindingAdapterPosition(); int currentPosition = getBindingAdapterPosition();
@ -2419,7 +2419,7 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType())); scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType()));
} }
VoteThing.votePost(mActivity, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingListener() { VoteThing.votePost(mActivity, retrofit, mAccessToken, new VoteThing.VoteThingListener() {
@Override @Override
public void onVoteThingSuccess(int position1) { public void onVoteThingSuccess(int position1) {
int currentPosition = getBindingAdapterPosition(); int currentPosition = getBindingAdapterPosition();
@ -2480,7 +2480,7 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
SavePost savePost = new SavePost(); SavePost savePost = new SavePost();
if (post.isSaved()) { if (post.isSaved()) {
saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp); saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp);
savePost.unsaveThing(mOauthRetrofit, mAccessToken, post.getId(), savePost.unsaveThing(retrofit, mAccessToken, post.getId(),
new SaveThing.SaveThingListener() { new SaveThing.SaveThingListener() {
@Override @Override
public void success() { public void success() {
@ -2504,7 +2504,7 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
}); });
} else { } else {
saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp); saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
savePost.saveThing(mOauthRetrofit, mAccessToken, post.getId(), savePost.saveThing(retrofit, mAccessToken, post.getId(),
new SaveThing.SaveThingListener() { new SaveThing.SaveThingListener() {
@Override @Override
public void success() { public void success() {
@ -3653,7 +3653,7 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType())); scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType()));
} }
VoteThing.votePost(mActivity, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingListener() { VoteThing.votePost(mActivity, retrofit, mAccessToken, new VoteThing.VoteThingListener() {
@Override @Override
public void onVoteThingSuccess(int position1) { public void onVoteThingSuccess(int position1) {
int currentPosition = getBindingAdapterPosition(); int currentPosition = getBindingAdapterPosition();
@ -3745,7 +3745,7 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType())); scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType()));
} }
VoteThing.votePost(mActivity, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingListener() { VoteThing.votePost(mActivity, retrofit, mAccessToken, new VoteThing.VoteThingListener() {
@Override @Override
public void onVoteThingSuccess(int position1) { public void onVoteThingSuccess(int position1) {
int currentPosition = getBindingAdapterPosition(); int currentPosition = getBindingAdapterPosition();
@ -3808,7 +3808,7 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
SavePost savePost = new SavePost(); SavePost savePost = new SavePost();
if (post.isSaved()) { if (post.isSaved()) {
saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp); saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp);
savePost.unsaveThing(mOauthRetrofit, mAccessToken, post.getId(), savePost.unsaveThing(retrofit, mAccessToken, post.getId(),
new SaveThing.SaveThingListener() { new SaveThing.SaveThingListener() {
@Override @Override
public void success() { public void success() {
@ -3832,7 +3832,7 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
}); });
} else { } else {
saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp); saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
savePost.saveThing(mOauthRetrofit, mAccessToken, post.getId(), savePost.saveThing(retrofit, mAccessToken, post.getId(),
new SaveThing.SaveThingListener() { new SaveThing.SaveThingListener() {
@Override @Override
public void success() { public void success() {

View File

@ -1374,7 +1374,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
}); });
} else { } else {
mSaveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp); mSaveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
savePost.saveThing(mOauthRetrofit, mAccessToken, mPost.getId(), savePost.saveThing(mRetrofit, mAccessToken, mPost.getId(),
new SaveThing.SaveThingListener() { new SaveThing.SaveThingListener() {
@Override @Override
public void success() { public void success() {

View File

@ -146,7 +146,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
private SharedPreferences mSharedPreferences; private SharedPreferences mSharedPreferences;
private SharedPreferences mCurrentAccountSharedPreferences; private SharedPreferences mCurrentAccountSharedPreferences;
private Executor mExecutor; private Executor mExecutor;
private Retrofit mOauthRetrofit; private Retrofit retrofit;
private Retrofit mGfycatRetrofit; private Retrofit mGfycatRetrofit;
private Retrofit mRedgifsRetrofit; private Retrofit mRedgifsRetrofit;
private Provider<StreamableAPI> mStreamableApiProvider; private Provider<StreamableAPI> mStreamableApiProvider;
@ -250,7 +250,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
mSharedPreferences = sharedPreferences; mSharedPreferences = sharedPreferences;
mCurrentAccountSharedPreferences = currentAccountSharedPreferences; mCurrentAccountSharedPreferences = currentAccountSharedPreferences;
mExecutor = executor; mExecutor = executor;
mOauthRetrofit = oauthRetrofit; retrofit = oauthRetrofit;
mGfycatRetrofit = gfycatRetrofit; mGfycatRetrofit = gfycatRetrofit;
mRedgifsRetrofit = redgifsRetrofit; mRedgifsRetrofit = redgifsRetrofit;
mStreamableApiProvider = streamableApiProvider; mStreamableApiProvider = streamableApiProvider;
@ -2434,7 +2434,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType())); scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType()));
} }
VoteThing.votePost(mActivity, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingListener() { VoteThing.votePost(mActivity, retrofit, mAccessToken, new VoteThing.VoteThingListener() {
@Override @Override
public void onVoteThingSuccess(int position1) { public void onVoteThingSuccess(int position1) {
int currentPosition = getBindingAdapterPosition(); int currentPosition = getBindingAdapterPosition();
@ -2530,7 +2530,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType())); scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType()));
} }
VoteThing.votePost(mActivity, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingListener() { VoteThing.votePost(mActivity, retrofit, mAccessToken, new VoteThing.VoteThingListener() {
@Override @Override
public void onVoteThingSuccess(int position1) { public void onVoteThingSuccess(int position1) {
int currentPosition = getBindingAdapterPosition(); int currentPosition = getBindingAdapterPosition();
@ -2591,7 +2591,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
SavePost savePost = new SavePost(); SavePost savePost = new SavePost();
if (post.isSaved()) { if (post.isSaved()) {
saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp); saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp);
savePost.unsaveThing(mOauthRetrofit, mAccessToken, post.getId(), savePost.unsaveThing(retrofit, mAccessToken, post.getId(),
new SaveThing.SaveThingListener() { new SaveThing.SaveThingListener() {
@Override @Override
public void success() { public void success() {
@ -2615,7 +2615,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
}); });
} else { } else {
saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp); saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
savePost.saveThing(mOauthRetrofit, mAccessToken, post.getId(), savePost.saveThing(retrofit, mAccessToken, post.getId(),
new SaveThing.SaveThingListener() { new SaveThing.SaveThingListener() {
@Override @Override
public void success() { public void success() {
@ -3793,7 +3793,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType())); scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType()));
} }
VoteThing.votePost(mActivity, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingListener() { VoteThing.votePost(mActivity, retrofit, mAccessToken, new VoteThing.VoteThingListener() {
@Override @Override
public void onVoteThingSuccess(int position1) { public void onVoteThingSuccess(int position1) {
int currentPosition = getBindingAdapterPosition(); int currentPosition = getBindingAdapterPosition();
@ -3889,7 +3889,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType())); scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType()));
} }
VoteThing.votePost(mActivity, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingListener() { VoteThing.votePost(mActivity, retrofit, mAccessToken, new VoteThing.VoteThingListener() {
@Override @Override
public void onVoteThingSuccess(int position1) { public void onVoteThingSuccess(int position1) {
int currentPosition = getBindingAdapterPosition(); int currentPosition = getBindingAdapterPosition();
@ -3952,7 +3952,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
SavePost postSave = new SavePost(); SavePost postSave = new SavePost();
if (post.isSaved()) { if (post.isSaved()) {
saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp); saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp);
postSave.unsaveThing(mOauthRetrofit, mAccessToken, post.getId(), postSave.unsaveThing(retrofit, mAccessToken, post.getId(),
new SaveThing.SaveThingListener() { new SaveThing.SaveThingListener() {
@Override @Override
public void success() { public void success() {
@ -3976,7 +3976,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
}); });
} else { } else {
saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp); saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
postSave.saveThing(mOauthRetrofit, mAccessToken, post.getId(), postSave.saveThing(retrofit, mAccessToken, post.getId(),
new SaveThing.SaveThingListener() { new SaveThing.SaveThingListener() {
@Override @Override
public void success() { public void success() {

View File

@ -380,7 +380,7 @@ public class HistoryPostFragment extends Fragment implements FragmentCommunicato
if (historyType == HISTORY_TYPE_READ_POSTS) { if (historyType == HISTORY_TYPE_READ_POSTS) {
postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.HISTORY_POST_LAYOUT_READ_POST, defaultPostLayout); postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.HISTORY_POST_LAYOUT_READ_POST, defaultPostLayout);
mAdapter = new HistoryPostRecyclerViewAdapter(activity, this, mExecutor, mOauthRetrofit, mGfycatRetrofit, mAdapter = new HistoryPostRecyclerViewAdapter(activity, this, mExecutor, mRetrofit.getRetrofit(), mGfycatRetrofit,
mRedgifsRetrofit, mStreamableApiProvider, mCustomThemeWrapper, locale, mRedgifsRetrofit, mStreamableApiProvider, mCustomThemeWrapper, locale,
accessToken, accountName, postType, postLayout, true, accessToken, accountName, postType, postLayout, true,
mSharedPreferences, mCurrentAccountSharedPreferences, mNsfwAndSpoilerSharedPreferences, mSharedPreferences, mCurrentAccountSharedPreferences, mNsfwAndSpoilerSharedPreferences,