diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPostDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPostDetailActivity.java index 3954bf2a..96d48c08 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPostDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPostDetailActivity.java @@ -45,6 +45,8 @@ import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; import java.util.concurrent.Executor; import javax.inject.Inject; @@ -128,6 +130,7 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele ArrayList posts; @State Post post; + public Map authorIcons = new HashMap<>(); private FragmentManager fragmentManager; private SlidrInterface mSlidrInterface; private SectionsPagerAdapter sectionsPagerAdapter; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsListingRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsListingRecyclerViewAdapter.java index 5800244d..6666d9a0 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsListingRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsListingRecyclerViewAdapter.java @@ -388,6 +388,9 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter mVisibleComments; private Locale mLocale; + private RequestManager mGlide; private String mSingleCommentId; private boolean mIsSingleCommentThreadMode; private boolean mVoteButtonsOnTheRight; @@ -159,6 +164,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter { + if (authorName.equals(comment.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 { + mGlide.load(comment.getAuthorIconUrl()) + .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); + } + if (mShowElapsedTime) { ((CommentViewHolder) holder).commentTimeTextView.setText( Utils.getElapsedTime(mActivity, comment.getCommentTimeMillis())); @@ -1036,6 +1061,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter { + activity.authorIcons.put(authorName, iconImageUrl); + loadIconListener.loadIconSuccess(authorName, iconImageUrl); + }); + } + } + @Override public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) { inflater.inflate(R.menu.view_post_detail_fragment, menu); @@ -1952,4 +1965,8 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic mPostAdapter.setCanPlayVideo(hasWindowsFocus); } } + + public interface LoadIconListener { + void loadIconSuccess(String authorName, String iconUrl); + } } diff --git a/app/src/main/res/layout/item_comment.xml b/app/src/main/res/layout/item_comment.xml index e64206d7..a97db526 100644 --- a/app/src/main/res/layout/item_comment.xml +++ b/app/src/main/res/layout/item_comment.xml @@ -24,35 +24,48 @@ android:paddingStart="16dp" android:paddingEnd="16dp"> + + + app:layout_constraintBottom_toTopOf="@id/author_flair_text_view_item_post_comment" + app:layout_constraintStart_toEndOf="@id/author_icon_image_view_item_post_comment" + app:layout_constraintEnd_toStartOf="@+id/barrier" + app:layout_constraintHorizontal_bias="0" + app:layout_constraintTop_toTopOf="parent" /> @@ -71,9 +84,9 @@ android:id="@+id/comment_time_text_view_item_post_comment" android:layout_width="0dp" android:layout_height="wrap_content" + android:fontFamily="?attr/font_family" android:gravity="end" android:textSize="?attr/font_default" - android:fontFamily="?attr/font_family" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toTopOf="parent" /> @@ -85,6 +98,13 @@ app:barrierDirection="start" app:constraint_referenced_ids="top_score_text_view_item_post_comment" /> + +