Fix unable to select contact from list bug.

fork-5.53.8
Cody Henthorne 2021-12-09 13:28:50 -05:00
rodzic 761d70851c
commit 3b9cfc8e5a
3 zmienionych plików z 12 dodań i 5 usunięć

Wyświetl plik

@ -765,8 +765,8 @@ public final class ContactSelectionListFragment extends LoggingFragment
public interface OnContactSelectedListener {
/** Provides an opportunity to disallow selecting an item. Call the callback with false to disallow, or true to allow it. */
void onBeforeContactSelected(Optional<RecipientId> recipientId, String number, Consumer<Boolean> callback);
void onContactDeselected(Optional<RecipientId> recipientId, String number);
void onBeforeContactSelected(Optional<RecipientId> recipientId, @Nullable String number, Consumer<Boolean> callback);
void onContactDeselected(Optional<RecipientId> recipientId, @Nullable String number);
void onSelectionChanged();
}

Wyświetl plik

@ -113,7 +113,7 @@ class SelectRecipientsFragment : LoggingFragment(), ContactSelectionListFragment
return mode or ContactsCursorLoader.DisplayMode.FLAG_HIDE_GROUPS_V1
}
override fun onBeforeContactSelected(recipientId: Optional<RecipientId>, number: String, callback: Consumer<Boolean>) {
override fun onBeforeContactSelected(recipientId: Optional<RecipientId>, number: String?, callback: Consumer<Boolean>) {
if (recipientId.isPresent) {
viewModel.select(recipientId.get())
callback.accept(true)
@ -123,7 +123,7 @@ class SelectRecipientsFragment : LoggingFragment(), ContactSelectionListFragment
}
}
override fun onContactDeselected(recipientId: Optional<RecipientId>, number: String) {
override fun onContactDeselected(recipientId: Optional<RecipientId>, number: String?) {
if (recipientId.isPresent) {
viewModel.deselect(recipientId.get())
updateAddToProfile()

Wyświetl plik

@ -71,6 +71,14 @@ public class ContactSelectionListItem extends ConstraintLayout implements Recipi
ViewUtil.setTextViewGravityStart(this.nameView, getContext());
}
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
if (recipient != null) {
recipient.observeForever(this);
}
}
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
@ -150,7 +158,6 @@ public class ContactSelectionListItem extends ConstraintLayout implements Recipi
public void unbind() {
if (recipient != null) {
recipient.removeForeverObserver(this);
recipient = null;
}
}