From d1740f77d1692f5c0772833f4683ad4aa464f8aa Mon Sep 17 00:00:00 2001 From: TacoTheDank Date: Fri, 24 Sep 2021 21:28:33 -0400 Subject: Fix some deprecations --- .../AcknowledgementRecyclerViewAdapter.java | 2 +- .../adapters/AwardRecyclerViewAdapter.java | 2 +- .../FlairBottomSheetRecyclerViewAdapter.java | 10 +++--- .../adapters/FollowedUsersRecyclerViewAdapter.java | 40 +++++++++++----------- .../adapters/MessageRecyclerViewAdapter.java | 4 +-- .../MultiRedditListingRecyclerViewAdapter.java | 20 +++++------ .../PostFilterUsageRecyclerViewAdapter.java | 2 +- .../PrivateMessagesDetailRecyclerViewAdapter.java | 4 +-- .../adapters/ReportReasonRecyclerViewAdapter.java | 10 +++--- .../adapters/RulesRecyclerViewAdapter.java | 6 ++-- .../SearchActivityRecyclerViewAdapter.java | 4 +-- .../SelectedSubredditsRecyclerViewAdapter.java | 6 ++-- .../adapters/UserFlairRecyclerViewAdapter.java | 6 ++-- .../infinityforreddit/utils/APIUtils.java | 2 +- .../infinityforreddit/utils/UploadImageUtils.java | 2 +- 15 files changed, 60 insertions(+), 60 deletions(-) (limited to 'app/src/main') diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/AcknowledgementRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/AcknowledgementRecyclerViewAdapter.java index c6f7ee56..9d9b0843 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/AcknowledgementRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/AcknowledgementRecyclerViewAdapter.java @@ -35,7 +35,7 @@ public class AcknowledgementRecyclerViewAdapter extends RecyclerView.Adapter { - itemOnClickListener.onClick(awards.get(getAdapterPosition())); + itemOnClickListener.onClick(awards.get(getBindingAdapterPosition())); }); } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/FlairBottomSheetRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/FlairBottomSheetRecyclerViewAdapter.java index 4d738aa3..399726d0 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/FlairBottomSheetRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/FlairBottomSheetRecyclerViewAdapter.java @@ -44,7 +44,7 @@ public class FlairBottomSheetRecyclerViewAdapter extends RecyclerView.Adapter { View dialogView = ((Activity) context).getLayoutInflater().inflate(R.layout.dialog_edit_flair, null); @@ -59,7 +59,7 @@ public class FlairBottomSheetRecyclerViewAdapter extends RecyclerView.Adapter { - Flair flair = flairs.get(holder.getAdapterPosition()); + Flair flair = flairs.get(holder.getBindingAdapterPosition()); flair.setText(flairEditText.getText().toString()); itemClickListener.onClick(flair); }) @@ -68,13 +68,13 @@ public class FlairBottomSheetRecyclerViewAdapter extends RecyclerView.Adapter holder.editFlairImageView.performClick()); } else { - holder.itemView.setOnClickListener(view -> itemClickListener.onClick(flairs.get(holder.getAdapterPosition()))); + holder.itemView.setOnClickListener(view -> itemClickListener.onClick(flairs.get(holder.getBindingAdapterPosition()))); } - holder.flairTextView.setText(flairs.get(holder.getAdapterPosition()).getText()); + holder.flairTextView.setText(flairs.get(holder.getBindingAdapterPosition()).getText()); } @Override diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/FollowedUsersRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/FollowedUsersRecyclerViewAdapter.java index a077569e..89bae0c9 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/FollowedUsersRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/FollowedUsersRecyclerViewAdapter.java @@ -106,8 +106,8 @@ public class FollowedUsersRecyclerViewAdapter extends RecyclerView.Adapter 0) ? mFavoriteSubscribedUserData.size() + 2 : 0; - if (!mSubscribedUserData.get(viewHolder.getAdapterPosition() - offset).getIconUrl().equals("")) { - glide.load(mSubscribedUserData.get(viewHolder.getAdapterPosition() - offset).getIconUrl()) + if (!mSubscribedUserData.get(viewHolder.getBindingAdapterPosition() - offset).getIconUrl().equals("")) { + glide.load(mSubscribedUserData.get(viewHolder.getBindingAdapterPosition() - offset).getIconUrl()) .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))) .error(glide.load(R.drawable.subreddit_default_icon) .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))) @@ -117,16 +117,16 @@ public class FollowedUsersRecyclerViewAdapter extends RecyclerView.Adapter { - int position = getAdapterPosition() - 1; + int position = getBindingAdapterPosition() - 1; if(position >= 0 && mFavoriteSubscribedUserData.size() > position) { Intent intent = new Intent(mContext, ViewUserDetailActivity.class); intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, mFavoriteSubscribedUserData.get(position).getName()); @@ -214,7 +214,7 @@ public class FollowedUsersRecyclerViewAdapter extends RecyclerView.Adapter { - int position = getAdapterPosition() - 1; + int position = getBindingAdapterPosition() - 1; if(position >= 0 && mFavoriteSubscribedUserData.size() > position) { if(mFavoriteSubscribedUserData.get(position).isFavorite()) { favoriteImageView.setImageResource(R.drawable.ic_favorite_border_24dp); @@ -225,7 +225,7 @@ public class FollowedUsersRecyclerViewAdapter extends RecyclerView.Adapter= 0 && mFavoriteSubscribedUserData.size() > position) { mFavoriteSubscribedUserData.get(position).setFavorite(false); } @@ -235,7 +235,7 @@ public class FollowedUsersRecyclerViewAdapter extends RecyclerView.Adapter= 0 && mFavoriteSubscribedUserData.size() > position) { mFavoriteSubscribedUserData.get(position).setFavorite(true); } @@ -251,7 +251,7 @@ public class FollowedUsersRecyclerViewAdapter extends RecyclerView.Adapter= 0 && mFavoriteSubscribedUserData.size() > position) { mFavoriteSubscribedUserData.get(position).setFavorite(true); } @@ -261,7 +261,7 @@ public class FollowedUsersRecyclerViewAdapter extends RecyclerView.Adapter= 0 && mFavoriteSubscribedUserData.size() > position) { mFavoriteSubscribedUserData.get(position).setFavorite(false); } @@ -290,7 +290,7 @@ public class FollowedUsersRecyclerViewAdapter extends RecyclerView.Adapter { int offset = (mFavoriteSubscribedUserData != null && mFavoriteSubscribedUserData.size() > 0) ? mFavoriteSubscribedUserData.size() + 2 : 0; - int position = getAdapterPosition() - offset; + int position = getBindingAdapterPosition() - offset; if(position >= 0 && mSubscribedUserData.size() > position) { Intent intent = new Intent(mContext, ViewUserDetailActivity.class); intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, mSubscribedUserData.get(position).getName()); @@ -301,7 +301,7 @@ public class FollowedUsersRecyclerViewAdapter extends RecyclerView.Adapter { int offset = (mFavoriteSubscribedUserData != null && mFavoriteSubscribedUserData.size() > 0) ? mFavoriteSubscribedUserData.size() + 2 : 0; - int position = getAdapterPosition() - offset; + int position = getBindingAdapterPosition() - offset; if(position >= 0 && mSubscribedUserData.size() > position) { if(mSubscribedUserData.get(position).isFavorite()) { @@ -313,7 +313,7 @@ public class FollowedUsersRecyclerViewAdapter extends RecyclerView.Adapter= 0 && mSubscribedUserData.size() > position) { mSubscribedUserData.get(position).setFavorite(false); } @@ -323,7 +323,7 @@ public class FollowedUsersRecyclerViewAdapter extends RecyclerView.Adapter= 0 && mSubscribedUserData.size() > position) { mSubscribedUserData.get(position).setFavorite(true); } @@ -339,7 +339,7 @@ public class FollowedUsersRecyclerViewAdapter extends RecyclerView.Adapter= 0 && mSubscribedUserData.size() > position) { mSubscribedUserData.get(position).setFavorite(true); } @@ -349,7 +349,7 @@ public class FollowedUsersRecyclerViewAdapter extends RecyclerView.Adapter= 0 && mSubscribedUserData.size() > position) { mSubscribedUserData.get(position).setFavorite(false); } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/MessageRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/MessageRecyclerViewAdapter.java index 2c283669..3925d59c 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/MessageRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/MessageRecyclerViewAdapter.java @@ -201,7 +201,7 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter replies = message.getReplies(); Message displayedMessage; @@ -240,7 +240,7 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter 0) ? mFavoriteMultiReddits.size() + 2 : 0; - MultiReddit multiReddit = mMultiReddits.get(holder.getAdapterPosition() - offset); + MultiReddit multiReddit = mMultiReddits.get(holder.getBindingAdapterPosition() - offset); name = multiReddit.getDisplayName(); iconUrl = multiReddit.getIconUrl(); if(multiReddit.isFavorite()) { @@ -134,7 +134,7 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter< new FavoriteMultiReddit.FavoriteMultiRedditListener() { @Override public void success() { - int position = holder.getAdapterPosition() - offset; + int position = holder.getBindingAdapterPosition() - offset; if(position >= 0 && mMultiReddits.size() > position) { mMultiReddits.get(position).setFavorite(false); } @@ -144,7 +144,7 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter< @Override public void failed() { Toast.makeText(mActivity, R.string.thing_unfavorite_failed, Toast.LENGTH_SHORT).show(); - int position = holder.getAdapterPosition() - offset; + int position = holder.getBindingAdapterPosition() - offset; if(position >= 0 && mMultiReddits.size() > position) { mMultiReddits.get(position).setFavorite(true); } @@ -160,7 +160,7 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter< new FavoriteMultiReddit.FavoriteMultiRedditListener() { @Override public void success() { - int position = holder.getAdapterPosition() - offset; + int position = holder.getBindingAdapterPosition() - offset; if(position >= 0 && mMultiReddits.size() > position) { mMultiReddits.get(position).setFavorite(true); } @@ -170,7 +170,7 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter< @Override public void failed() { Toast.makeText(mActivity, R.string.thing_favorite_failed, Toast.LENGTH_SHORT).show(); - int position = holder.getAdapterPosition() - offset; + int position = holder.getBindingAdapterPosition() - offset; if(position >= 0 && mMultiReddits.size() > position) { mMultiReddits.get(position).setFavorite(false); } @@ -202,7 +202,7 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter< } ((MultiRedditViewHolder) holder).multiRedditNameTextView.setText(name); } else if (holder instanceof FavoriteMultiRedditViewHolder) { - MultiReddit multiReddit = mFavoriteMultiReddits.get(holder.getAdapterPosition() - 1); + MultiReddit multiReddit = mFavoriteMultiReddits.get(holder.getBindingAdapterPosition() - 1); String name = multiReddit.getDisplayName(); String iconUrl = multiReddit.getIconUrl(); if(multiReddit.isFavorite()) { @@ -220,7 +220,7 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter< new FavoriteMultiReddit.FavoriteMultiRedditListener() { @Override public void success() { - int position = holder.getAdapterPosition() - 1; + int position = holder.getBindingAdapterPosition() - 1; if(position >= 0 && mFavoriteMultiReddits.size() > position) { mFavoriteMultiReddits.get(position).setFavorite(false); } @@ -230,7 +230,7 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter< @Override public void failed() { Toast.makeText(mActivity, R.string.thing_unfavorite_failed, Toast.LENGTH_SHORT).show(); - int position = holder.getAdapterPosition() - 1; + int position = holder.getBindingAdapterPosition() - 1; if(position >= 0 && mFavoriteMultiReddits.size() > position) { mFavoriteMultiReddits.get(position).setFavorite(true); } @@ -246,7 +246,7 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter< new FavoriteMultiReddit.FavoriteMultiRedditListener() { @Override public void success() { - int position = holder.getAdapterPosition() - 1; + int position = holder.getBindingAdapterPosition() - 1; if(position >= 0 && mFavoriteMultiReddits.size() > position) { mFavoriteMultiReddits.get(position).setFavorite(true); } @@ -256,7 +256,7 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter< @Override public void failed() { Toast.makeText(mActivity, R.string.thing_favorite_failed, Toast.LENGTH_SHORT).show(); - int position = holder.getAdapterPosition() - 1; + int position = holder.getBindingAdapterPosition() - 1; if(position >= 0 && mFavoriteMultiReddits.size() > position) { mFavoriteMultiReddits.get(position).setFavorite(false); } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostFilterUsageRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostFilterUsageRecyclerViewAdapter.java index d6d4c938..e8c92df3 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostFilterUsageRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostFilterUsageRecyclerViewAdapter.java @@ -86,7 +86,7 @@ public class PostFilterUsageRecyclerViewAdapter extends RecyclerView.Adapter { - onItemClickListener.onClick(postFilterUsages.get(getAdapterPosition())); + onItemClickListener.onClick(postFilterUsages.get(getBindingAdapterPosition())); }); } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PrivateMessagesDetailRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PrivateMessagesDetailRecyclerViewAdapter.java index 190b8ad5..8fe78d79 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PrivateMessagesDetailRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PrivateMessagesDetailRecyclerViewAdapter.java @@ -117,10 +117,10 @@ public class PrivateMessagesDetailRecyclerViewAdapter extends RecyclerView.Adapt @Override public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { Message message; - if (holder.getAdapterPosition() == 0) { + if (holder.getBindingAdapterPosition() == 0) { message = mMessage; } else { - message = mMessage.getReplies().get(holder.getAdapterPosition() - 1); + message = mMessage.getReplies().get(holder.getBindingAdapterPosition() - 1); } if (message != null) { if (holder instanceof MessageViewHolder) { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/ReportReasonRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/ReportReasonRecyclerViewAdapter.java index 5e5572ff..80e57a5a 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/ReportReasonRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/ReportReasonRecyclerViewAdapter.java @@ -42,9 +42,9 @@ public class ReportReasonRecyclerViewAdapter extends RecyclerView.Adapter= generalReasons.size()) { - reportReason = rules.get(holder.getAdapterPosition() - generalReasons.size()); + reportReason = rules.get(holder.getBindingAdapterPosition() - generalReasons.size()); } else { - reportReason = generalReasons.get(holder.getAdapterPosition()); + reportReason = generalReasons.get(holder.getBindingAdapterPosition()); } ((ReasonViewHolder) holder).reasonTextView.setText(reportReason.getReportReason()); ((ReasonViewHolder) holder).checkBox.setChecked(reportReason.isSelected()); @@ -119,10 +119,10 @@ public class ReportReasonRecyclerViewAdapter extends RecyclerView.Adapter= generalReasons.size()) { - rules.get(getAdapterPosition() - generalReasons.size()).setSelected(checkBox.isChecked()); + if (getBindingAdapterPosition() >= generalReasons.size()) { + rules.get(getBindingAdapterPosition() - generalReasons.size()).setSelected(checkBox.isChecked()); } else { - generalReasons.get(getAdapterPosition()).setSelected(checkBox.isChecked()); + generalReasons.get(getBindingAdapterPosition()).setSelected(checkBox.isChecked()); } }); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/RulesRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/RulesRecyclerViewAdapter.java index 51d55400..454ecdd4 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/RulesRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/RulesRecyclerViewAdapter.java @@ -82,11 +82,11 @@ public class RulesRecyclerViewAdapter extends RecyclerView.Adapter { if (recentSearchQueries != null && !recentSearchQueries.isEmpty()) { - itemOnClickListener.onClick(recentSearchQueries.get(getAdapterPosition()).getSearchQuery()); + itemOnClickListener.onClick(recentSearchQueries.get(getBindingAdapterPosition()).getSearchQuery()); } }); deleteImageView.setOnClickListener(view -> { - itemOnClickListener.onDelete(recentSearchQueries.get(getAdapterPosition())); + itemOnClickListener.onDelete(recentSearchQueries.get(getBindingAdapterPosition())); }); } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/SelectedSubredditsRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/SelectedSubredditsRecyclerViewAdapter.java index e6bbe441..ad57d3ba 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/SelectedSubredditsRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/SelectedSubredditsRecyclerViewAdapter.java @@ -39,10 +39,10 @@ public class SelectedSubredditsRecyclerViewAdapter extends RecyclerView.Adapter< @Override public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { if (holder instanceof SubredditViewHolder) { - ((SubredditViewHolder) holder).subredditNameTextView.setText(subreddits.get(holder.getAdapterPosition())); + ((SubredditViewHolder) holder).subredditNameTextView.setText(subreddits.get(holder.getBindingAdapterPosition())); ((SubredditViewHolder) holder).deleteButton.setOnClickListener(view -> { - subreddits.remove(holder.getAdapterPosition()); - notifyItemRemoved(holder.getAdapterPosition()); + subreddits.remove(holder.getBindingAdapterPosition()); + notifyItemRemoved(holder.getBindingAdapterPosition()); }); } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/UserFlairRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/UserFlairRecyclerViewAdapter.java index 1f05380b..d260bb0d 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/UserFlairRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/UserFlairRecyclerViewAdapter.java @@ -43,7 +43,7 @@ public class UserFlairRecyclerViewAdapter extends RecyclerView.Adapter { - itemClickListener.onClick(userFlairs.get(getAdapterPosition()), false); + itemClickListener.onClick(userFlairs.get(getBindingAdapterPosition()), false); }); editUserFlairImageView.setOnClickListener(view -> { - itemClickListener.onClick(userFlairs.get(getAdapterPosition()), true); + itemClickListener.onClick(userFlairs.get(getBindingAdapterPosition()), true); }); } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/APIUtils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/APIUtils.java index 465a31eb..5078692d 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/APIUtils.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/APIUtils.java @@ -120,6 +120,6 @@ public class APIUtils { } public static RequestBody getRequestBody(String s) { - return RequestBody.create(MediaType.parse("text/plain"), s); + return RequestBody.create(s, MediaType.parse("text/plain")); } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/UploadImageUtils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/UploadImageUtils.java index c7b5f728..e0bf7c25 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/UploadImageUtils.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/UploadImageUtils.java @@ -50,7 +50,7 @@ public class UploadImageUtils { image.compress(Bitmap.CompressFormat.JPEG, 100, stream); byte[] byteArray = stream.toByteArray(); - RequestBody fileBody = RequestBody.create(MediaType.parse("application/octet-stream"), byteArray); + RequestBody fileBody = RequestBody.create(byteArray, MediaType.parse("application/octet-stream")); MultipartBody.Part fileToUpload = MultipartBody.Part.createFormData("file", "post_image.jpg", fileBody); RedditAPI uploadMediaToAWSApi = uploadMediaRetrofit.create(RedditAPI.class); -- cgit v1.2.3