Stop observing LiveRecipient in contact list when detached.
This commit is contained in:
parent
cae5dad5d8
commit
ff633ddd59
2 changed files with 11 additions and 2 deletions
|
@ -141,7 +141,7 @@ public class ContactSelectionListAdapter extends CursorRecyclerViewAdapter<ViewH
|
|||
|
||||
@Override
|
||||
public void unbind(@NonNull GlideRequests glideRequests) {
|
||||
getView().unbind(glideRequests);
|
||||
getView().unbind();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -71,6 +71,12 @@ public class ContactSelectionListItem extends ConstraintLayout implements Recipi
|
|||
ViewUtil.setTextViewGravityStart(this.nameView, getContext());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
unbind();
|
||||
}
|
||||
|
||||
public void set(@NonNull GlideRequests glideRequests,
|
||||
@Nullable RecipientId recipientId,
|
||||
int type,
|
||||
|
@ -92,6 +98,9 @@ public class ContactSelectionListItem extends ConstraintLayout implements Recipi
|
|||
this.recipient = null;
|
||||
this.contactPhotoImage.setAvatar(glideRequests, null, false);
|
||||
} else if (recipientId != null) {
|
||||
if (this.recipient != null) {
|
||||
this.recipient.removeForeverObserver(this);
|
||||
}
|
||||
this.recipient = Recipient.live(recipientId);
|
||||
this.recipient.observeForever(this);
|
||||
}
|
||||
|
@ -150,7 +159,7 @@ public class ContactSelectionListItem extends ConstraintLayout implements Recipi
|
|||
this.checkBox.setEnabled(enabled);
|
||||
}
|
||||
|
||||
public void unbind(GlideRequests glideRequests) {
|
||||
public void unbind() {
|
||||
if (recipient != null) {
|
||||
recipient.removeForeverObserver(this);
|
||||
recipient = null;
|
||||
|
|
Loading…
Add table
Reference in a new issue