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 {
comment.setSaved(true);
saveComment.saveThing(mOauthRetrofit, mAccessToken, comment.getId(), new SaveThing.SaveThingListener() {
saveComment.saveThing(mRetrofit.getRetrofit(), mAccessToken, comment.getId(), new SaveThing.SaveThingListener() {
@Override
public void success() {
ViewPostDetailFragment fragment = sectionsPagerAdapter.getCurrentFragment();

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -380,7 +380,7 @@ public class HistoryPostFragment extends Fragment implements FragmentCommunicato
if (historyType == HISTORY_TYPE_READ_POSTS) {
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,
accessToken, accountName, postType, postLayout, true,
mSharedPreferences, mCurrentAccountSharedPreferences, mNsfwAndSpoilerSharedPreferences,