improve performance

This commit is contained in:
adbenitez
2022-08-25 16:11:55 -04:00
parent b66117de99
commit f4e693ca63
4 changed files with 12 additions and 24 deletions
@@ -1579,7 +1579,8 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|| eventId == DcContext.DC_EVENT_MSG_READ
|| eventId == DcContext.DC_EVENT_MSG_DELIVERED)
&& event.getData1Int() == chatId) {
titleView.updateStatus(dcContext, chatId);
DcContact contact = recipient.getDcContact();
titleView.setSeenRecently(contact!=null? contact.isSeenRecently() : false);
}
}
@@ -167,14 +167,8 @@ public class ConversationListItem extends RelativeLayout
this.avatar.setAvatar(glideRequests, recipient, false);
if (recipient.isMultiUserRecipient()) {
avatar.setSeenRecently(false);
} else {
DcContext dcContext = DcHelper.getContext(getContext());
int[] members = dcContext.getChatContacts((int)chatId);
DcContact contact = dcContext.getContact(members.length>=1? members[0] : 0);
avatar.setSeenRecently(contact.isSeenRecently());
}
DcContact contact = recipient.getDcContact();
avatar.setSeenRecently(contact!=null? contact.isSeenRecently() : false);
fromView.setCompoundDrawablesWithIntrinsicBounds(
thread.isMuted()? R.drawable.ic_volume_off_grey600_18dp : 0,
@@ -140,15 +140,8 @@ public class ConversationTitleView extends RelativeLayout {
subtitle.setVisibility(View.VISIBLE);
}
public void updateStatus(DcContext dcContext, int chatId) {
boolean isOnline = false;
if(!dcContext.getChat(chatId).isMultiUser()) {
int[] members = dcContext.getChatContacts(chatId);
if(members.length>=1) {
isOnline = dcContext.getContact(members[0]).isSeenRecently();
}
}
avatar.setSeenRecently(isOnline);
public void setSeenRecently(boolean seenRecently) {
avatar.setSeenRecently(seenRecently);
}
public void hideAvatar() {
@@ -63,7 +63,6 @@ public class Recipient {
private @Nullable String profileName;
private @Nullable String profileAvatar;
// either dcChat or dcContact are set
private @Nullable DcChat dcChat;
private @Nullable DcContact dcContact;
@@ -125,7 +124,8 @@ public class Recipient {
DcContext dcContext = DcHelper.getContext(context);
int[] contacts = dcContext.getChatContacts(chatId);
if( contacts.length>=1 ) {
maybeSetSystemContactPhoto(context, dcContext.getContact(contacts[0]));
this.dcContact = dcContext.getContact(contacts[0]);
maybeSetSystemContactPhoto(context, this.dcContact);
}
}
}
@@ -194,12 +194,12 @@ public class Recipient {
public int getFallbackAvatarColor() {
int rgb = 0x00808080;
if(dcContact!=null) {
rgb = dcContact.getColor();
}
else if(dcChat!=null){
if(dcChat!=null) {
rgb = dcChat.getColor();
}
else if(dcContact!=null) {
rgb = dcContact.getColor();
}
int argb = Color.argb(0xFF, Color.red(rgb), Color.green(rgb), Color.blue(rgb));
return argb;
}