Skip to content

Commit

Permalink
Fix avatar tap in conversation multi-select mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
alan-signal authored and greyson-signal committed May 29, 2020
1 parent d708984 commit 526afd5
Showing 1 changed file with 19 additions and 23 deletions.
Expand Up @@ -84,6 +84,7 @@ public class ConversationListItem extends RelativeLayout
private TextView unreadIndicator;
private long lastSeen;
private ThreadRecord thread;
private boolean batchMode;

private int unreadCount;
private AvatarImageView contactPhotoImage;
Expand Down Expand Up @@ -203,10 +204,10 @@ public void bind(@NonNull ThreadRecord thread,

setStatusIcons(thread);
setThumbnailSnippet(thread);
setBatchState(batchMode);
setBatchMode(batchMode);
setRippleColor(recipient.get());
setUnreadIndicator(thread);
this.contactPhotoImage.setAvatar(glideRequests, recipient.get(), true);
this.contactPhotoImage.setAvatar(glideRequests, recipient.get(), !batchMode);
}

public void bind(@NonNull Recipient contact,
Expand All @@ -233,9 +234,9 @@ public void bind(@NonNull Recipient contact,
alertView.setNone();
thumbnailView.setVisibility(GONE);

setBatchState(false);
setBatchMode(false);
setRippleColor(contact);
contactPhotoImage.setAvatar(glideRequests, recipient.get(), true);
contactPhotoImage.setAvatar(glideRequests, recipient.get(), !batchMode);
}

public void bind(@NonNull MessageResult messageResult,
Expand All @@ -261,17 +262,19 @@ public void bind(@NonNull MessageResult messageResult,
alertView.setNone();
thumbnailView.setVisibility(GONE);

setBatchState(false);
setBatchMode(false);
setRippleColor(recipient.get());
contactPhotoImage.setAvatar(glideRequests, recipient.get(), true);
contactPhotoImage.setAvatar(glideRequests, recipient.get(), !batchMode);
}

@Override
public void unbind() {
if (this.recipient != null) {
this.recipient.removeForeverObserver(this);
this.recipient = null;
contactPhotoImage.setAvatar(glideRequests, null, true);

setBatchMode(false);
contactPhotoImage.setAvatar(glideRequests, null, !batchMode);
}

if (this.groupAddedBy != null) {
Expand All @@ -280,8 +283,9 @@ public void unbind() {
}
}

private void setBatchState(boolean batch) {
setSelected(batch && selectedThreads.contains(threadId));
private void setBatchMode(boolean batchMode) {
this.batchMode = batchMode;
setSelected(batchMode && selectedThreads.contains(threadId));
}

public Recipient getRecipient() {
Expand All @@ -304,7 +308,7 @@ public long getLastSeen() {
return lastSeen;
}

private @NonNull CharSequence getTrimmedSnippet(@NonNull CharSequence snippet) {
private static @NonNull CharSequence getTrimmedSnippet(@NonNull CharSequence snippet) {
return snippet.length() <= MAX_SNIPPET_LENGTH ? snippet
: snippet.subSequence(0, MAX_SNIPPET_LENGTH);
}
Expand All @@ -316,19 +320,15 @@ private void setThumbnailSnippet(ThreadRecord thread) {

LayoutParams subjectParams = (RelativeLayout.LayoutParams)this.subjectContainer .getLayoutParams();
subjectParams.addRule(RelativeLayout.LEFT_OF, R.id.thumbnail);
if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN_MR1) {
subjectParams.addRule(RelativeLayout.START_OF, R.id.thumbnail);
}
subjectParams.addRule(RelativeLayout.START_OF, R.id.thumbnail);
this.subjectContainer.setLayoutParams(subjectParams);
this.post(new ThumbnailPositioner(thumbnailView, archivedView, deliveryStatusIndicator, dateView));
} else {
this.thumbnailView.setVisibility(View.GONE);

LayoutParams subjectParams = (RelativeLayout.LayoutParams)this.subjectContainer.getLayoutParams();
subjectParams.addRule(RelativeLayout.LEFT_OF, R.id.status);
if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN_MR1) {
subjectParams.addRule(RelativeLayout.START_OF, R.id.status);
}
subjectParams.addRule(RelativeLayout.START_OF, R.id.status);
this.subjectContainer.setLayoutParams(subjectParams);
}
}
Expand Down Expand Up @@ -373,7 +373,7 @@ private void setUnreadIndicator(ThreadRecord thread) {
@Override
public void onRecipientChanged(@NonNull Recipient recipient) {
fromView.setText(recipient, unreadCount == 0);
contactPhotoImage.setAvatar(glideRequests, recipient, true);
contactPhotoImage.setAvatar(glideRequests, recipient, !batchMode);
setRippleColor(recipient);
}

Expand All @@ -399,14 +399,10 @@ public void run() {
(archivedView.getWidth() + deliveryStatusView.getWidth()) > dateView.getWidth())
{
thumbnailParams.addRule(RelativeLayout.LEFT_OF, R.id.status);
if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN_MR1) {
thumbnailParams.addRule(RelativeLayout.START_OF, R.id.status);
}
thumbnailParams.addRule(RelativeLayout.START_OF, R.id.status);
} else {
thumbnailParams.addRule(RelativeLayout.LEFT_OF, R.id.date);
if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN_MR1) {
thumbnailParams.addRule(RelativeLayout.START_OF, R.id.date);
}
thumbnailParams.addRule(RelativeLayout.START_OF, R.id.date);
}

thumbnailView.setLayoutParams(thumbnailParams);
Expand Down

0 comments on commit 526afd5

Please sign in to comment.