Stop observing LiveRecipient in contact list when detached.

fork-5.53.8
Greyson Parrelli 2021-11-04 11:09:27 -04:00
rodzic cae5dad5d8
commit ff633ddd59
2 zmienionych plików z 11 dodań i 2 usunięć

Wyświetl plik

@ -141,7 +141,7 @@ public class ContactSelectionListAdapter extends CursorRecyclerViewAdapter<ViewH
@Override @Override
public void unbind(@NonNull GlideRequests glideRequests) { public void unbind(@NonNull GlideRequests glideRequests) {
getView().unbind(glideRequests); getView().unbind();
} }
@Override @Override

Wyświetl plik

@ -71,6 +71,12 @@ public class ContactSelectionListItem extends ConstraintLayout implements Recipi
ViewUtil.setTextViewGravityStart(this.nameView, getContext()); ViewUtil.setTextViewGravityStart(this.nameView, getContext());
} }
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
unbind();
}
public void set(@NonNull GlideRequests glideRequests, public void set(@NonNull GlideRequests glideRequests,
@Nullable RecipientId recipientId, @Nullable RecipientId recipientId,
int type, int type,
@ -92,6 +98,9 @@ public class ContactSelectionListItem extends ConstraintLayout implements Recipi
this.recipient = null; this.recipient = null;
this.contactPhotoImage.setAvatar(glideRequests, null, false); this.contactPhotoImage.setAvatar(glideRequests, null, false);
} else if (recipientId != null) { } else if (recipientId != null) {
if (this.recipient != null) {
this.recipient.removeForeverObserver(this);
}
this.recipient = Recipient.live(recipientId); this.recipient = Recipient.live(recipientId);
this.recipient.observeForever(this); this.recipient.observeForever(this);
} }
@ -150,7 +159,7 @@ public class ContactSelectionListItem extends ConstraintLayout implements Recipi
this.checkBox.setEnabled(enabled); this.checkBox.setEnabled(enabled);
} }
public void unbind(GlideRequests glideRequests) { public void unbind() {
if (recipient != null) { if (recipient != null) {
recipient.removeForeverObserver(this); recipient.removeForeverObserver(this);
recipient = null; recipient = null;