mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-11-10 12:47:26 +01:00
Display comment avatar only if it is the right user (#1191)
Condition in callback for loading avatar url is almost always true[1]. So it would load avatar even if the viewholder got bound to another comment. Ideally the solution would be to update the comment just like now, then find current position of the comment and call onItemChanged. However you cannot call onItemChanged from onBindViewHolder and that is a problem because callback can be executed synchronously. So instead we just check that viewholder is bound to some comment and that bound comment's author matches initially requested author. [1] The only case I know when it is false is when that comment got deleted and its author got replaced with "[deleted]" before the callback got executed
This commit is contained in:
parent
191df66a3b
commit
78496e080f
@ -402,12 +402,16 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
||||
if (comment.getAuthorIconUrl() == null) {
|
||||
mFragment.loadIcon(comment.getAuthor(), (authorName, iconUrl) -> {
|
||||
if (authorName.equals(comment.getAuthor())) {
|
||||
comment.setAuthorIconUrl(iconUrl);
|
||||
}
|
||||
|
||||
Comment currentComment = getCurrentComment(holder);
|
||||
if (currentComment != null && authorName.equals(currentComment.getAuthor())) {
|
||||
mGlide.load(iconUrl)
|
||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
||||
.error(mGlide.load(R.drawable.subreddit_default_icon)
|
||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))))
|
||||
.into(((CommentViewHolder) holder).authorIconImageView);
|
||||
comment.setAuthorIconUrl(iconUrl);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
@ -529,12 +533,16 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
||||
if (comment.getAuthorIconUrl() == null) {
|
||||
mFragment.loadIcon(comment.getAuthor(), (authorName, iconUrl) -> {
|
||||
if (authorName.equals(comment.getAuthor())) {
|
||||
comment.setAuthorIconUrl(iconUrl);
|
||||
}
|
||||
|
||||
Comment currentComment = getCurrentComment(holder);
|
||||
if (currentComment != null && authorName.equals(currentComment.getAuthor())) {
|
||||
mGlide.load(iconUrl)
|
||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
||||
.error(mGlide.load(R.drawable.subreddit_default_icon)
|
||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))))
|
||||
.into(((CommentFullyCollapsedViewHolder) holder).authorIconImageView);
|
||||
comment.setAuthorIconUrl(iconUrl);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user