Skip to content

Commit

Permalink
Loads multiple avatars for new followers and post/comment likes
Browse files Browse the repository at this point in the history
  • Loading branch information
Antonis Lilis committed Feb 6, 2024
1 parent 94a46ef commit 504e7d3
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -203,12 +203,7 @@ class NotesAdapter(
} else {
noteViewHolder.textDetail.visibility = View.GONE
}
val avatarUrl = GravatarUtils.fixGravatarUrl(note.iconURL, avatarSize)
imageManager!!.loadIntoCircle(
noteViewHolder.imageAvatar,
ImageType.AVATAR_WITH_BACKGROUND,
avatarUrl
)
noteViewHolder.loadAvatars(note)
noteViewHolder.unreadNotificationView.isVisible = note.isUnread

// request to load more comments when we near the end
Expand All @@ -229,6 +224,63 @@ class NotesAdapter(
noteViewHolder.headerText.layoutParams = layoutParams
}

private fun NoteViewHolder.loadAvatars(note: Note) {
if (note.canShowMultipleAvatars()) {
if(note.iconURLs!!.size == 2) {
imageAvatar.visibility = View.INVISIBLE
twoAvatarsView.visibility = View.VISIBLE
threeAvatarsView.visibility = View.INVISIBLE
val avatarUrl = GravatarUtils.fixGravatarUrl(note.iconURL, avatarSize)
val avatarUrl2 = GravatarUtils.fixGravatarUrl(note.iconURLs!![1], avatarSize)
imageManager?.loadIntoCircle(
twoAvatars1,
ImageType.AVATAR_WITH_BACKGROUND,
avatarUrl2
)
imageManager?.loadIntoCircle(
twoAvatars2,
ImageType.AVATAR_WITH_BACKGROUND,
avatarUrl
)
} else {
imageAvatar.visibility = View.INVISIBLE
twoAvatarsView.visibility = View.INVISIBLE
threeAvatarsView.visibility = View.VISIBLE
val avatarUrl = GravatarUtils.fixGravatarUrl(note.iconURL, avatarSize)
val avatarUrl2 = GravatarUtils.fixGravatarUrl(note.iconURLs!![1], avatarSize)
val avatarUrl3 = GravatarUtils.fixGravatarUrl(note.iconURLs!![2], avatarSize)
imageManager?.loadIntoCircle(
threeAvatars1,
ImageType.AVATAR_WITH_BACKGROUND,
avatarUrl3
)
imageManager?.loadIntoCircle(
threeAvatars2,
ImageType.AVATAR_WITH_BACKGROUND,
avatarUrl2
)
imageManager?.loadIntoCircle(
threeAvatars3,
ImageType.AVATAR_WITH_BACKGROUND,
avatarUrl
)
}
} else {
imageAvatar.visibility = View.VISIBLE
twoAvatarsView.visibility = View.INVISIBLE
threeAvatarsView.visibility = View.INVISIBLE
val avatarUrl = GravatarUtils.fixGravatarUrl(note.iconURL, avatarSize)
imageManager?.loadIntoCircle(
imageAvatar,
ImageType.AVATAR_WITH_BACKGROUND,
avatarUrl
)
}
}

private fun Note.canShowMultipleAvatars() =
(isFollowType || isLikeType || isCommentLikeType) && iconURLs != null && iconURLs!!.size > 1

private fun handleMaxLines(subject: TextView, detail: TextView) {
subject.viewTreeObserver.addOnPreDrawListener(object : ViewTreeObserver.OnPreDrawListener {
override fun onPreDraw(): Boolean {
Expand Down Expand Up @@ -280,6 +332,13 @@ class NotesAdapter(
val textSubjectNoticon: TextView
val textDetail: TextView
val imageAvatar: ImageView
val twoAvatarsView: View
val twoAvatars1: ImageView
val twoAvatars2: ImageView
val threeAvatarsView: View
val threeAvatars1: ImageView
val threeAvatars2: ImageView
val threeAvatars3: ImageView
val unreadNotificationView: View

init {
Expand All @@ -289,6 +348,13 @@ class NotesAdapter(
textSubjectNoticon = checkNotNull(view.findViewById(R.id.note_subject_noticon))
textDetail = checkNotNull(view.findViewById(R.id.note_detail))
imageAvatar = checkNotNull(view.findViewById(R.id.note_avatar))
twoAvatars1 = checkNotNull(view.findViewById(R.id.two_avatars_1))
twoAvatars2 = checkNotNull(view.findViewById(R.id.two_avatars_2))
threeAvatars1 = checkNotNull(view.findViewById(R.id.three_avatars_1))
threeAvatars2 = checkNotNull(view.findViewById(R.id.three_avatars_2))
threeAvatars3 = checkNotNull(view.findViewById(R.id.three_avatars_3))
twoAvatarsView = checkNotNull(view.findViewById(R.id.two_avatars_view))
threeAvatarsView = checkNotNull(view.findViewById(R.id.three_avatars_view))
unreadNotificationView = checkNotNull(view.findViewById(R.id.notification_unread))
contentView.setOnClickListener(onClickListener)
}
Expand Down
1 change: 0 additions & 1 deletion WordPress/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,6 @@
<dimen name="notifications_content_margin">0dp</dimen>
<dimen name="notifications_avatar_sz">48dp</dimen>
<dimen name="notifications_avatar_margin_start">18dp</dimen>
<dimen name="notifications_avatar_size">28dp</dimen>
<dimen name="notifications_text_indent_sz">22dp</dimen>
<dimen name="notification_comment_padded_frame_bg_offset">14dp</dimen> <!-- results in 6dp border -->
<dimen name="notification_comment_frame_bg_border_width">6dp</dimen>
Expand Down

0 comments on commit 504e7d3

Please sign in to comment.