kopia lustrzana https://github.com/ryukoposting/Signal-Android
Fix some timing issues around recipient events.
rodzic
c2a6963a6d
commit
39709c8d64
|
@ -16,6 +16,7 @@ import org.thoughtcrime.securesms.R;
|
||||||
import org.thoughtcrime.securesms.components.AvatarImageView;
|
import org.thoughtcrime.securesms.components.AvatarImageView;
|
||||||
import org.thoughtcrime.securesms.components.FromTextView;
|
import org.thoughtcrime.securesms.components.FromTextView;
|
||||||
import org.thoughtcrime.securesms.mms.GlideRequests;
|
import org.thoughtcrime.securesms.mms.GlideRequests;
|
||||||
|
import org.thoughtcrime.securesms.phonenumbers.PhoneNumberFormatter;
|
||||||
import org.thoughtcrime.securesms.recipients.LiveRecipient;
|
import org.thoughtcrime.securesms.recipients.LiveRecipient;
|
||||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||||
import org.thoughtcrime.securesms.recipients.RecipientForeverObserver;
|
import org.thoughtcrime.securesms.recipients.RecipientForeverObserver;
|
||||||
|
@ -95,8 +96,9 @@ public class ContactSelectionListItem extends LinearLayout implements RecipientF
|
||||||
Recipient recipientSnapshot = recipient != null ? recipient.get() : null;
|
Recipient recipientSnapshot = recipient != null ? recipient.get() : null;
|
||||||
|
|
||||||
if (recipientSnapshot != null && !recipientSnapshot.isResolving()) {
|
if (recipientSnapshot != null && !recipientSnapshot.isResolving()) {
|
||||||
name = recipientSnapshot.getDisplayName(getContext());
|
contactName = recipientSnapshot.getDisplayName(getContext());
|
||||||
} else {
|
name = contactName;
|
||||||
|
} else if (recipient != null) {
|
||||||
name = "";
|
name = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,6 +214,10 @@ public class ContactSelectionListItem extends LinearLayout implements RecipientF
|
||||||
@Override
|
@Override
|
||||||
public void onRecipientChanged(@NonNull Recipient recipient) {
|
public void onRecipientChanged(@NonNull Recipient recipient) {
|
||||||
if (this.recipient != null && this.recipient.getId().equals(recipient.getId())) {
|
if (this.recipient != null && this.recipient.getId().equals(recipient.getId())) {
|
||||||
|
contactName = recipient.getDisplayName(getContext());
|
||||||
|
contactAbout = recipient.getCombinedAboutAndEmoji();
|
||||||
|
contactNumber = PhoneNumberFormatter.prettyPrint(recipient.getE164().or(""));
|
||||||
|
|
||||||
contactPhotoImage.setAvatar(glideRequests, recipient, false);
|
contactPhotoImage.setAvatar(glideRequests, recipient, false);
|
||||||
setText(recipient, contactType, contactName, contactNumber, contactLabel, contactAbout);
|
setText(recipient, contactType, contactName, contactNumber, contactLabel, contactAbout);
|
||||||
smsTag.setVisibility(recipient.isRegistered() ? GONE : VISIBLE);
|
smsTag.setVisibility(recipient.isRegistered() ? GONE : VISIBLE);
|
||||||
|
|
|
@ -50,9 +50,11 @@ public final class LiveRecipient {
|
||||||
this.groupDatabase = DatabaseFactory.getGroupDatabase(context);
|
this.groupDatabase = DatabaseFactory.getGroupDatabase(context);
|
||||||
this.observers = new CopyOnWriteArraySet<>();
|
this.observers = new CopyOnWriteArraySet<>();
|
||||||
this.foreverObserver = recipient -> {
|
this.foreverObserver = recipient -> {
|
||||||
|
ThreadUtil.postToMain(() -> {
|
||||||
for (RecipientForeverObserver o : observers) {
|
for (RecipientForeverObserver o : observers) {
|
||||||
o.onRecipientChanged(recipient);
|
o.onRecipientChanged(recipient);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
};
|
};
|
||||||
this.refreshForceNotify = new MutableLiveData<>(new Object());
|
this.refreshForceNotify = new MutableLiveData<>(new Object());
|
||||||
this.observableLiveData = LiveDataUtil.combineLatest(LiveDataUtil.distinctUntilChanged(liveData, Recipient::hasSameContent),
|
this.observableLiveData = LiveDataUtil.combineLatest(LiveDataUtil.distinctUntilChanged(liveData, Recipient::hasSameContent),
|
||||||
|
|
Ładowanie…
Reference in New Issue