Skip to content

Commit

Permalink
Fix PostCompactBaseViewHolder implementation in PostRecyclerViewAdapter.
Browse files Browse the repository at this point in the history
  • Loading branch information
Docile-Alligator committed Oct 15, 2024
1 parent d2c240d commit f414b8f
Showing 1 changed file with 25 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ public void onBindViewHolder(@NonNull final RecyclerView.ViewHolder holder, int
if (post.getAuthorIconUrl() == null) {
mFragment.loadIcon(post.getAuthor(), false, (subredditOrUserName, iconUrl) -> {
if (mActivity != null && getItemCount() > 0 && post.getAuthor().equals(subredditOrUserName)) {
if (iconUrl == null || iconUrl.equals("")) {
if (iconUrl == null || iconUrl.isEmpty()) {
mGlide.load(R.drawable.subreddit_default_icon)
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
.into(((PostViewHolder) holder).iconGifImageView);
Expand All @@ -629,7 +629,7 @@ public void onBindViewHolder(@NonNull final RecyclerView.ViewHolder holder, int
}
}
});
} else if (!post.getAuthorIconUrl().equals("")) {
} else if (!post.getAuthorIconUrl().isEmpty()) {
mGlide.load(post.getAuthorIconUrl())
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
.error(mGlide.load(R.drawable.subreddit_default_icon)
Expand All @@ -644,7 +644,7 @@ public void onBindViewHolder(@NonNull final RecyclerView.ViewHolder holder, int
if (post.getSubredditIconUrl() == null) {
mFragment.loadIcon(post.getSubredditName(), true, (subredditOrUserName, iconUrl) -> {
if (mActivity != null && getItemCount() > 0 && post.getSubredditName().equals(subredditOrUserName)) {
if (iconUrl == null || iconUrl.equals("")) {
if (iconUrl == null || iconUrl.isEmpty()) {
mGlide.load(R.drawable.subreddit_default_icon)
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
.into(((PostViewHolder) holder).iconGifImageView);
Expand All @@ -661,7 +661,7 @@ public void onBindViewHolder(@NonNull final RecyclerView.ViewHolder holder, int
}
}
});
} else if (!post.getSubredditIconUrl().equals("")) {
} else if (!post.getSubredditIconUrl().isEmpty()) {
mGlide.load(post.getSubredditIconUrl())
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
.error(mGlide.load(R.drawable.subreddit_default_icon)
Expand All @@ -678,7 +678,7 @@ public void onBindViewHolder(@NonNull final RecyclerView.ViewHolder holder, int
String authorName = post.isAuthorDeleted() ? post.getSubredditName() : post.getAuthor();
mFragment.loadIcon(authorName, post.isAuthorDeleted(), (subredditOrUserName, iconUrl) -> {
if (mActivity != null && getItemCount() > 0) {
if (iconUrl == null || iconUrl.equals("") && authorName.equals(subredditOrUserName)) {
if (iconUrl == null || iconUrl.isEmpty() && authorName.equals(subredditOrUserName)) {
mGlide.load(R.drawable.subreddit_default_icon)
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
.into(((PostViewHolder) holder).iconGifImageView);
Expand All @@ -695,7 +695,7 @@ public void onBindViewHolder(@NonNull final RecyclerView.ViewHolder holder, int
}
}
});
} else if (!post.getAuthorIconUrl().equals("")) {
} else if (!post.getAuthorIconUrl().isEmpty()) {
mGlide.load(post.getAuthorIconUrl())
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
.error(mGlide.load(R.drawable.subreddit_default_icon)
Expand Down Expand Up @@ -738,7 +738,7 @@ public void onBindViewHolder(@NonNull final RecyclerView.ViewHolder holder, int
((PostViewHolder) holder).nsfwTextView.setVisibility(View.VISIBLE);
}

if (post.isSpoiler()) {
if (((PostViewHolder) holder).spoilerTextView != null && post.isSpoiler()) {
((PostViewHolder) holder).spoilerTextView.setVisibility(View.VISIBLE);
}

Expand Down Expand Up @@ -941,7 +941,7 @@ public void onLayoutChange(View v, int left, int top, int right, int bottom, int
(post.isNSFW() && mNeedBlurNsfw && !(mDoNotBlurNsfwInNsfwSubreddits && mFragment != null && mFragment.getIsNsfwSubreddit())) || (post.isSpoiler() && mNeedBlurSpoiler));
}
} else if (holder instanceof PostTextTypeViewHolder) {
if (!mHideTextPostContent && !post.isSpoiler() && post.getSelfTextPlainTrimmed() != null && !post.getSelfTextPlainTrimmed().equals("")) {
if (!mHideTextPostContent && !post.isSpoiler() && post.getSelfTextPlainTrimmed() != null && !post.getSelfTextPlainTrimmed().isEmpty()) {
((PostTextTypeViewHolder) holder).contentTextView.setVisibility(View.VISIBLE);
if (post.isRead()) {
((PostTextTypeViewHolder) holder).contentTextView.setTextColor(mReadPostContentColor);
Expand Down Expand Up @@ -1941,7 +1941,11 @@ void setBaseView(AspectRatioGifImageView iconGifImageView,
TextView postTimeTextView,
TextView titleTextView,
@Nullable CustomTextView typeTextView,
@Nullable ImageView archivedImageView,
@Nullable ImageView lockedImageView,
@Nullable ImageView crosspostImageView,
@Nullable CustomTextView nsfwTextView,
@Nullable CustomTextView spoilerTextView,
@Nullable CustomTextView flairTextView,
MaterialButton upvoteButton,
TextView scoreTextView,
Expand All @@ -1953,6 +1957,15 @@ void setBaseView(AspectRatioGifImageView iconGifImageView,
this.stickiedPostImageView = stickiedPostImageView;
this.postTimeTextView = postTimeTextView;
this.titleTextView = titleTextView;

this.typeTextView = typeTextView;
this.archivedImageView = archivedImageView;
this.lockedImageView = lockedImageView;
this.crosspostImageView = crosspostImageView;
this.nsfwTextView = nsfwTextView;
this.spoilerTextView = spoilerTextView;
this.flairTextView = flairTextView;

this.upvoteButton = upvoteButton;
this.scoreTextView = scoreTextView;
this.downvoteButton = downvoteButton;
Expand Down Expand Up @@ -3581,17 +3594,7 @@ void setItemViewBackgroundColor(boolean isReadPost) {

public class PostCompactBaseViewHolder extends PostViewHolder {
TextView nameTextView;
ImageView stickiedPostImageView;
TextView postTimeTextView;
ConstraintLayout titleAndImageConstraintLayout;
TextView titleTextView;
CustomTextView typeTextView;
ImageView archivedImageView;
ImageView lockedImageView;
ImageView crosspostImageView;
CustomTextView nsfwTextView;
CustomTextView spoilerTextView;
CustomTextView flairTextView;
TextView linkTextView;
RelativeLayout relativeLayout;
ProgressBar progressBar;
Expand Down Expand Up @@ -3643,7 +3646,11 @@ void setBaseView(AspectRatioGifImageView iconGifImageView,
postTimeTextView,
titleTextView,
typeTextView,
archivedImageView,
lockedImageView,
crosspostImageView,
nsfwTextView,
spoilerTextView,
flairTextView,
upvoteButton,
scoreTextView,
Expand All @@ -3653,17 +3660,7 @@ void setBaseView(AspectRatioGifImageView iconGifImageView,
shareButton);

this.nameTextView = nameTextView;
this.stickiedPostImageView = stickiedPostImageView;
this.postTimeTextView = postTimeTextView;
this.titleAndImageConstraintLayout = titleAndImageConstraintLayout;
this.titleTextView = titleTextView;
this.typeTextView = typeTextView;
this.archivedImageView = archivedImageView;
this.lockedImageView = lockedImageView;
this.crosspostImageView = crosspostImageView;
this.nsfwTextView = nsfwTextView;
this.spoilerTextView = spoilerTextView;
this.flairTextView = flairTextView;
this.linkTextView = linkTextView;
this.relativeLayout = relativeLayout;
this.progressBar = progressBar;
Expand Down

0 comments on commit f414b8f

Please sign in to comment.